Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2846. Add syntax and whitespaces tests #2896

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

sgrekhov
Copy link
Contributor

No description provided.

Copy link
Member

@eernstg eernstg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

I'm a little worried about the wording in some cases (basically, we can't say something which would be like "check that if can't start with a +" in the extreme, because the answer is simply "but it doesn't!"), and I've tried to come up with something that doesn't have this kind of built-in contradiction.

Comment on lines 16 to 17
/// @description Checks that it is a syntax error if a `pathSegment` starts or
/// ends with a '/'.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's somewhat confusing to read "a pathSegment starts or ends with a /" because that is never true. How would we be able to test the handling of something that can't happen? The following is perhaps better:

Suggested change
/// @description Checks that it is a syntax error if a `pathSegment` starts or
/// ends with a '/'.
/// @description Checks that it is a syntax error if a `/` is encountered when
/// a `packagePath` is expected, or a `;` is encountered when a `pathSegment`
/// is expected.

The point is that the grammar clearly indicates that a packagePath is expected when the token import has been accepted, and the next token isn't a string literal. So we're necessarily trying to recognize a packagePath when the first / is encountered, and that must be reported as a syntax error (or some other compile-time error, because a parser is always allowed to report syntax errors in that way).

For the / that occurs after a pathSegment, it is definitely not a syntax error in its own right: We could have another pathSegment, and the / would then fit in just fine. So it's the semicolon which is a syntax error. Again, I'm focusing on the non-terminal which is actually expected when the semicolon is encountered. We're doing pathSegment ( '/' pathSegment )* which means that we expect to see a pathSegment after each occurrence of a /, and a pathSegment cannot start with the token ;, which must give rise to a syntax error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a typo. There should be packagePath instead of pathSegment. Thank you for noticing, changed to the suggested wording.

Comment on lines 16 to 17
/// @description Checks that it is a syntax error if a `segmentComponent` is
/// empty.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// @description Checks that it is a syntax error if a `segmentComponent` is
/// empty.
/// @description Checks that it is a syntax error if a `.` is encountered
/// when a `packagePath` is expected. Ditto if a `;` is encountered
/// when a `segmentComponent` is expected. Ditto if a `.` is encountered
/// when a `pathSegment` is expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Contributor Author

@sgrekhov sgrekhov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Updated, PTAL.

Comment on lines 16 to 17
/// @description Checks that it is a syntax error if a `pathSegment` starts or
/// ends with a '/'.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a typo. There should be packagePath instead of pathSegment. Thank you for noticing, changed to the suggested wording.

Comment on lines 16 to 17
/// @description Checks that it is a syntax error if a `segmentComponent` is
/// empty.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Member

@eernstg eernstg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eernstg eernstg merged commit 8d0c6ae into dart-lang:master Sep 26, 2024
1 of 2 checks passed
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Sep 27, 2024
2024-09-26 sgrekhov22@gmail.com dart-lang/co19#2846. Add syntax and whitespaces tests (dart-lang/co19#2896)
2024-09-26 sgrekhov22@gmail.com Fixes dart-lang/co19#2892. Change expected errors positions. (dart-lang/co19#2894)
2024-09-26 sgrekhov22@gmail.com Fixes dart-lang/co19#2893. In case of ambiguous export don't expect an error on the first export (dart-lang/co19#2895)
2024-09-26 sgrekhov22@gmail.com dart-lang/co19#2846. Add static semantics tests for unquoted imports (dart-lang/co19#2891)
2024-09-25 sgrekhov22@gmail.com dart-lang/co19#2846. Add unquoted imports tests for path separator (dart-lang/co19#2889)
2024-09-25 sgrekhov22@gmail.com dart-lang/co19#2846. Add unquoted imports tests for parts (dart-lang/co19#2890)
2024-09-24 sgrekhov22@gmail.com dart-lang/co19#2559. Update `defining_augmentation_*` tests (dart-lang/co19#2884)
2024-09-24 sgrekhov22@gmail.com dart-lang/co19#2825. Add more grammar tests (dart-lang/co19#2882)
2024-09-24 sgrekhov22@gmail.com Fixes dart-lang/co19#2878. Use pid for unique temp name (dart-lang/co19#2883)
2024-09-24 sgrekhov22@gmail.com Fixes dart-lang/co19#2877. Catch and ignore exceptions during temp file deletion (dart-lang/co19#2881)
2024-09-24 sgrekhov22@gmail.com Fixes dart-lang/co19#2879. Fix racy code in length_A01_t01.dart (dart-lang/co19#2880)
2024-09-23 sgrekhov22@gmail.com dart-lang/co19#2846. Add unquoted imports tests for keywords (dart-lang/co19#2886)
2024-09-23 sgrekhov22@gmail.com Fixes dart-lang/co19#2887. Fix border type in static_analysis_extension_types_A08_t11.dart (dart-lang/co19#2888)

Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try
Change-Id: Ibf63f6246db950981a0ee445764f9625bb69a9f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387161
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants