hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 667ccd3c4d5284c24936bdc2dfb745404391f185
parent 8c1ca1afada2eca337fd466a79e6fb46d2ffecfe
Author: Alexey Yerin <yyp@disroot.org>
Date:   Sun, 19 Feb 2023 22:52:40 +0300

hare::lex: error out when encountering an invalid exponent

Signed-off-by: Alexey Yerin <yyp@disroot.org>

Diffstat:
Mhare/lex/+test.ha | 9+++++++++
Mhare/lex/lex.ha | 2+-
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/hare/lex/+test.ha b/hare/lex/+test.ha @@ -332,6 +332,15 @@ fn loc(line: uint, col: uint) location = location { const s = lex(&lexer) as error as syntax; assert(s.1 == "unknown escape sequence"); + + // Regression: <X>e followed by another token used to cause a crash + const in = ['0': u8, 'e': u8, ')': u8]; + + let buf = bufio::fixed(in, mode::READ); + let lexer = init(&buf, "<test>"); + + const s = lex(&lexer) as error as syntax; + assert(s.1 == "expected exponent"); }; diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha @@ -549,7 +549,7 @@ fn lex_literal(lex: *lexer) (token | error) = { case let exp: int => yield exp; case strconv::invalid => - abort(); // Shouldn't be lexed in + return syntaxerr(mkloc(lex), "expected exponent"); case strconv::overflow => return syntaxerr(loc, "overflow in exponent"); };