syntax icon indicating copy to clipboard operation
syntax copied to clipboard

Making parser consistent with #542

Open Sehun0819 opened this issue 3 years ago • 5 comments

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

Sehun0819 avatar Jul 01 '22 07:07 Sehun0819

@cristianoc

Sehun0819 avatar Jul 01 '22 07:07 Sehun0819

How about checking for Eof before calling parseIdent.

cristianoc avatar Jul 01 '22 07:07 cristianoc

Please check #596. Seems to work, though a few code repeat was needed.

Sehun0819 avatar Jul 02 '22 07:07 Sehun0819

Looks good. Will take a closer look later.

cristianoc avatar Jul 02 '22 07:07 cristianoc

Thank you. Please let me know after taking a look later, as there are other similar cases to be treated.

Sehun0819 avatar Jul 02 '22 07:07 Sehun0819

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.

stale[bot] avatar May 28 '23 15:05 stale[bot]