-
Notifications
You must be signed in to change notification settings - Fork 38
Conversation
This turns potential infinite loops into runtime exceptions when calling |
Given how noisy it would be to give static guarantees, one can shoot for detection. When look-ahead it taken into account, real code never goes 1 further than the first Eol. This could then reported back as a syntax error message rather than crashing the compiler/editor. |
Summarising: preventing infinite loops arising from cases where one keeps on reading |
At the same time the result of #543 can be used to see where the logic had to be modified, and try to use that to construct infinite loop repros. Here is one: let foo = x =>
switch x {
| `${ |
Another case to investigate: https://github.com/rescript-lang/syntax/pull/543/files#r897400872 |
Parsing past Eof can lead to infinite loops, as it violates the assumptions of the termination checker. See: #540 This PR makes `Parser.next` assert false when called on Eof. This should not happen as one should check the token before calling `Parser.next`. The one exception is during lookahead, for which we provide a `nextUnsafe` function which does not make progress.
The last unclear case found during audit does not seem a real infinite loop. |
Added an issue to track better error messages: #550 |
Parsing past Eof can lead to infinite loops, as it violates the assumptions of the termination checker.
See: #540
This PR makes
Parser.next
assert false when called on Eof. This should not happen as one should check the token before callingParser.next
.The one exception is during lookahead, for which we provide a
nextUnsafe
function which does not make progress.