Making parser consistent with #542
Follow-up steps for #542 should be taken but I have no idea how to do.
- Motivating example(I’m guessing there would be a few more, I’ve not checked though):
#
Above simple code crashes the parser because parseIdent calls Parser.next with Eof, eventually violates an assertion of res_parser.ml added by #542. I thought it could be fixed easily by adding another pattern matching for Eof or substitute Parser.next with Parser.nextUnsafe(as far as it does not results another infinite loop), but neither pass the static analyzer. Any solution?
https://github.com/rescript-lang/syntax/blob/08029afafeef01cda2366c580b0b06d376b31d54/src/res_core.ml#L564-L586
@cristianoc
How about checking for Eof before calling parseIdent.
Please check #596. Seems to work, though a few code repeat was needed.
Looks good. Will take a closer look later.
Thank you. Please let me know after taking a look later, as there are other similar cases to be treated.
The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions.