Closed KimBruce closed 5 years ago
That’s not an error message, that’s a crash.
Look at lines 1047 and 1048 of lexer.grace. There are two requests, to removeLast and last, that re not guarded by first checking that indentStack is not empty. Checks should be added; if they fail, then the lexer should raise an error along the lines of “unmatched close brace found — did you forget an opening brace?”
Andrew P Black
On 20 Aug 2018, at 17:55, Kim Bruce notifications@github.com wrote:
Consider the following simple program:
if (true) then print "OK" } else { print "what?" } It is missing a "{" after the word "then". It generates the following very unhelpful error message:
BoundsError on line 673 of collectionsPrelude: index 0 out of bounds 1..0 raised at Exception.raise() at line 673 of collectionsPrelude requested from list.withAll().boundsCheck() at line 673 of collectionsPrelude requested from list.withAll().at() at line 677 of collectionsPrelude requested from list.withAll().last at line 402 of collectionsPrelude requested from checkIndentationReset at line 1047 of lexer requested from checkIndentation() at line 951 of lexer requested from indentationState.consume() at line 902 of lexer requested from block.apply at line 1518 of lexer requested from while()do() at line 1497 of lexer requested from block.apply() at line 1497 of lexer requested from extendedLineup.do() at line 1495 of lexer requested from for()do() at line 1495 of lexer requested from lexInputLines at line 1495 of lexer requested from lexfile(_) at line 1376 of lexer requested from block.apply at line 20 of compiler requested from module initialization in compiler requested on line 0 of . 672: if ( !(n >= 1) || !(n <= size)) then { 673: BoundsError.raise "index {n} out of bounds 1..{size}" 674: } — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Yes, the opening brace after “then” is missing — clearly an error, but it needed a better error message.
On Aug 21, 2018, at 10:04 AM, Andrew Black notifications@github.com wrote:
That’s not an error message, that’s a crash.
Look at lines 1047 and 1048 of lexer.grace. There are two requests, to removeLast and last, that re not guarded by first checking that indentStack is not empty. Checks should be added; if they fail, then the lexer should raise an error along the lines of “unmatched close brace found — did you forget an opening brace?”
Andrew P Black
On 20 Aug 2018, at 17:55, Kim Bruce notifications@github.com wrote:
Consider the following simple program:
if (true) then print "OK" } else { print "what?" } It is missing a "{" after the word "then". It generates the following very unhelpful error message:
BoundsError on line 673 of collectionsPrelude: index 0 out of bounds 1..0 raised at Exception.raise() at line 673 of collectionsPrelude requested from list.withAll().boundsCheck() at line 673 of collectionsPrelude requested from list.withAll().at() at line 677 of collectionsPrelude requested from list.withAll().last at line 402 of collectionsPrelude requested from checkIndentationReset at line 1047 of lexer requested from checkIndentation() at line 951 of lexer requested from indentationState.consume() at line 902 of lexer requested from block.apply at line 1518 of lexer requested from while()do() at line 1497 of lexer requested from block.apply() at line 1497 of lexer requested from extendedLineup.do() at line 1495 of lexer requested from for()do() at line 1495 of lexer requested from lexInputLines at line 1495 of lexer requested from lexfile(_) at line 1376 of lexer requested from block.apply at line 20 of compiler requested from module initialization in compiler requested on line 0 of . 672: if ( !(n >= 1) || !(n <= size)) then { 673: BoundsError.raise "index {n} out of bounds 1..{size}" 674: } — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gracelang/minigrace/issues/268#issuecomment-414748532, or mute the thread https://github.com/notifications/unsubscribe-auth/ABuh-kgJFIb2vfTYDy2q_vCw3sukEe2fks5uTD2tgaJpZM4WE7cs.
This has been fixed. The compiler highlights the closing brace on the third line, and says
Syntax error: there is no opening brace corresponding to this closing brace
Consider the following simple program:
It is missing a "{" after the word "then". It generates the following very unhelpful error message: