Bugfix - 'static meme x = x' should fail#16345
Conversation
There was a problem hiding this comment.
I've looked into the failures, and it seems this approach is not the best fit here, unfortunately.
Consider this case:
module Module
type T =
static
do ()This is the relevant part of the tokens:
MODULE_IS_HERE (1,0--1,6)
IDENT (1,7--1,13)
OBLOCKBEGIN (3,0--3,4)
TYPE_COMING_SOON (3,0--3,4)
TYPE_COMING_SOON (3,0--3,4)
TYPE_COMING_SOON (3,0--3,4)
TYPE_COMING_SOON (3,0--3,4)
TYPE_COMING_SOON (3,0--3,4)
TYPE_COMING_SOON (3,0--3,4)
TYPE_IS_HERE (3,0--3,4)
IDENT (3,5--3,6)
EQUALS (3,7--3,8)
OBLOCKBEGIN (5,4--5,10)
STATIC (5,4--5,10)
OBLOCKSEP (5,11--7,4)
ODO (7,4--7,6)
OBLOCKBEGIN (7,7--7,8)
We only have one token, OBLOCKSEP, to both recover at and to separate the declarations. It'd be much easier if there was a new block after static, but we probably have not enough tokens for LexFilter to insert it.
I think we should probably try checking flagsBuilderAndLeadingKeyword inside memberCore instead and reporting a manually defined error. It may be much simpler to do than to try to recover using different ways and will keep the failed cases working.
Excellent investigation, let me try your proposal then. |
|
@auduchinok : This looks cleaner now, none of the existing recovery scenarios is touched by it. |
…d-without-member-keyword-in-unexpected-way
Co-authored-by: Adam Boniecki <20281641+abonie@users.noreply.github.com>
…d-without-member-keyword-in-unexpected-way
Addresses #16342 .
The offending code is the following:
What happens is that 'meme' is treating as the function name, and average and x become arguments to it.
Instead, this should report an error about not having
staticfollowed bymember.The parser recovery remains the same, but now produces an error as it should - see the diff in SyntaxTreeTests.