DavidKinder / Inform6

The latest version of the Inform 6 compiler, used for generating interactive fiction games.
http://inform-fiction.org/
Other
199 stars 32 forks source link

parse_expression() now reports errors #247

Closed erkyrath closed 9 months ago

erkyrath commented 9 months ago

Fixes https://github.com/DavidKinder/Inform6/issues/246 .

The problem is that parse_expression() can generate an error, but the caller (the array statement) can't detect that fact to exit its loop.

Now parse_expression() returns a zero value with ERROR_MV set to indicate a blatant error. (Not every single error, but the ones which can lead to an infinite loop of errors. "Expected expression but found EOF" is the big offender here.)

ERROR_MV is ignored in most situations; the error has been reported, so we can just treat it as a regular zero and move on. But in two places in arrays.c, we check for it and break out of a loop. I may find other good places for this check in the future.

erkyrath commented 9 months ago

Test case, very simple: https://github.com/erkyrath/Inform6-Testing/blob/expr-error/src/unterm-array-test.inf