-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Topic/533 parse error #1847
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
Topic/533 parse error #1847
Conversation
@felixmulder @Blaisorblade I am happy to fix the conflicts, once the PR has been reviewed. |
Paolo is probably a good reviewer for this PR in my opinion :) so I'll delegate to him ;) |
I'll try but I can't reply very timely these days... |
Sorry @Blaisorblade, for a split-second while mentioning you, I forgot how busy you are these days. Maybe someone else can review this PR? Cheers and happy holidays! |
@@ -901,4 +901,31 @@ object messages { | |||
val msg = hl"trying to define package with same name as `$existing`" | |||
val explanation = "" | |||
} | |||
|
|||
case class DangelingThisInPath()(implicit ctx: Context) extends Message(34) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dangeling
-> Dangling
. (And given the delay, maybe recheck the ID 34).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed we're up to 35, so right now you'll need a 36. https://github.com/lampepfl/dotty/blob/bf9888edcd96f40f11260e6ad874eb27382f77ba/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala#L926
val msg = hl"""Expected an additional member selection after the keyword ${"this"}""" | ||
|
||
val importCode = | ||
"""import MyClass.this.member |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use OuterClass
instead of MyClass
? And even add class OuterClass { class InnerClass { ... } }
as context to show the point of MyClass.this
? I ask because it took me a (small) while to get the point MyClass.this
(I'll concede I might also be rusty).
@@ -504,7 +504,7 @@ object Parsers { | |||
def selector(t: Tree): Tree = | |||
atPos(startOffset(t), in.offset) { Select(t, ident()) } | |||
|
|||
/** Selectors ::= ident { `.' ident() | |||
/** Selectors ::= id { `.' id } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good commit. Possible further idea: mention id
in the comment for isIdent
, also given they're not consistent? So authors of other comments can also find the right terminal name to use in comments?
(Well, being consistent might be even better but I'm not sure what to pick).
But that shouldn't hold this PR.
LGTM apart from the comments (and even those are mostly optional) — sorry for the delay, I hadn't realized the review would be so quick! |
@Blaisorblade Thanks for the review. I provided some more context to the code examples in 21194ba |
The CI failure is on http://dotty-ci.epfl.ch/lampepfl/dotty/475/1 at line 6164-6173.* That seems to have to do with a testcase from 18bc638 in #1850 — for some reason only 1 error is being output instead of 2. Does this relate to switching error message from strings, or (in some complicated way) to adding BTW, with that change the caret is not on *OT for @jvican, assuming you picked Drone: I can't find a way to link to specific log lines in Drone logs like I'd do in these cases with Travis. Am I missing something? Or any chance you could please forward this feature request to the right people? |
I verified that, in deed, only one error is produced in presence of -- [E036] Syntax Error: examples/parser533.scala -------------------------------
3 |}
|^
|Expected an additional member selection after the keyword this
longer explanation available when compiling with `-explain`
-- [E025] Syntax Error: examples/parser533.scala -------------------------------
2 | type X = FooBar22.this // error
| ^^^^^^^^^^^^^
| identifier expected
longer explanation available when compiling with `-explain` |
@Blaisorblade, @b-studios, haven't looked too closely at this, but FYI: Error messages are pruned by UniqueMessagePositions.scala and HideNonSensicalMessages.scala. If positions are changed when modifying error messages, this is where they would be pruned out. The caret is placed on the Regarding Drone, http://discourse.drone.io/ is probably the appropriate place to make a feature request. They also have a gitter: https://gitter.im/drone/drone Cheers, |
Thanks @felixmulder for the caret explanation. Changing the error call to 2 | type X = FooBar22.this // error
| ^^^^^^^^^^^^^
| Expected an additional member selection after the keyword this @Blaisorblade Do you like that better? However, the second error message "identifier expected" is still pruned away since it is located at the same message position. |
FWIW, looking at the two messages, I'd say pruning away "identifier expected" is an improvement :-), and the new position is much better. TL;DR. I'd remove the second
Thanks, done here: |
@felixmulder Build now is successful. Is there something more I can do (like squashing, etc.), or are we ready to merge? |
I'd like the merge commit rebased away - otherwise LGTM 👍 |
d74f40f
to
bc8af8f
Compare
The following examples trigger the error message: val x: Foo.this = ??? // Also triggers the error: import foo.this // Additionally, also slays the compiler type X = Foo.this.type
To match the specs in https://github.com/lampepfl/dotty/blob/master/docs/syntax-summary.txt all occurences of Id, ident or Ident in comments have been replaced with the terminal `id`.
bc8af8f
to
feba6a4
Compare
@felixmulder I rebase the merge commit away and also squashed the typo-commit. |
Great, thanks a bunch! You're awesome 🎉 |
This pull request deals with "Parsers.scala:533". It is part of #1589.
Message Before
Message After
In addition to adding the required error message this pull request also fixes some inconsistencies with referring to identifier literals. While in the doc-comments one could find
Ident
,ident
,ident()
,Id
andid
, in the spec identifiers are always referred to asid
.