Implement syntactic merge checks for parameters.#4149
Merged
Conversation
Contributor
|
Please find another reviewer, as I'll be on vacation for the next two weeks. |
zygoloid
approved these changes
Jul 22, 2024
zygoloid
left a comment
Contributor
There was a problem hiding this comment.
Thanks!
Another edge case that would be useful to explicitly test (mostly because we've had discussions about using a different rule) is grouping parentheses differing between declarations.
Contributor
Author
Added test Also, made me realize I wasn't testing deduced params explicitly, so added that too. |
Contributor
Author
|
Per discussion, added a test for |
zygoloid
approved these changes
Jul 23, 2024
brymer-meneses
pushed a commit
to brymer-meneses/carbon-lang
that referenced
this pull request
Aug 15, 2024
Note this isn't implementing checking through imports. The parse node there is harder to access through the context, so would require examining the entity in order to get the import declaration, to get at the ImportIR. We also don't have a parse tree attached in that case, and would need to add one to SemIR::File. But I believe we do want to add that, so it's explicitly a TODO. Note GetTokenText re-lexes literal values, so there's a bit of potential overhead there. Not sure if we want a more efficient manner for comparing in cases like this.
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Jan 21, 2025
I believe `check_syntax` is already controlling the semantic vs syntactic merge, added in #4149. Other parts of the TODO are clarified per discussion. But this is tested, e.g. errors with the bool flipped: ``` impl i32 as I { + // CHECK:STDERR: method.carbon:[[@line+6]]:14: error: redeclaration syntax di ffers here [RedeclParamSyntaxDiffers] + // CHECK:STDERR: fn F[self: i32](other: i32) -> i32 = "int.sadd"; + // CHECK:STDERR: ^~~ + // CHECK:STDERR: method.carbon:[[@Line-7]]:14: note: comparing with previous declaration here [RedeclParamSyntaxPrevious] + // CHECK:STDERR: fn F[self: Self](other: Self) -> Self; + // CHECK:STDERR: ^~~~ fn F[self: i32](other: i32) -> i32 = "int.sadd"; } ```
dwblaikie
pushed a commit
to dwblaikie/carbon-lang
that referenced
this pull request
Jan 21, 2025
I believe `check_syntax` is already controlling the semantic vs syntactic merge, added in carbon-language#4149. Other parts of the TODO are clarified per discussion. But this is tested, e.g. errors with the bool flipped: ``` impl i32 as I { + // CHECK:STDERR: method.carbon:[[@line+6]]:14: error: redeclaration syntax di ffers here [RedeclParamSyntaxDiffers] + // CHECK:STDERR: fn F[self: i32](other: i32) -> i32 = "int.sadd"; + // CHECK:STDERR: ^~~ + // CHECK:STDERR: method.carbon:[[@Line-7]]:14: note: comparing with previous declaration here [RedeclParamSyntaxPrevious] + // CHECK:STDERR: fn F[self: Self](other: Self) -> Self; + // CHECK:STDERR: ^~~~ fn F[self: i32](other: i32) -> i32 = "int.sadd"; } ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note this isn't implementing checking through imports. The parse node there is harder to access through the context, so would require examining the entity in order to get the import declaration, to get at the ImportIR. We also don't have a parse tree attached in that case, and would need to add one to SemIR::File. But I believe we do want to add that, so it's explicitly a TODO.
Note GetTokenText re-lexes literal values, so there's a bit of potential overhead there. Not sure if we want a more efficient manner for comparing in cases like this.