hare

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

commit 7443677e5bf55989592a341eb9282ac348df9153
parent d4d01f7eeaf60f1631db382cdfc779de245148ed
Author: Sebastian <sebastian@sebsite.pw>
Date:   Fri,  8 Sep 2023 00:22:40 -0400

hare::parse: improve location in ident length error msg

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mhare/parse/ident.ha | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hare/parse/ident.ha b/hare/parse/ident.ha @@ -11,7 +11,9 @@ use strings; fn ident_trailing(lexer: *lex::lexer) ((ast::ident, bool) | error) = { let ident: []str = []; let trailing = false; - append(ident, want(lexer, ltok::NAME)?.1 as str); + const tok = want(lexer, ltok::NAME)?; + append(ident, tok.1 as str); + const loc = tok.2; let z = len(ident[0]); for (true) { match (try(lexer, ltok::DOUBLE_COLON)?) { @@ -31,8 +33,7 @@ fn ident_trailing(lexer: *lex::lexer) ((ast::ident, bool) | error) = { }; if (z > ast::IDENT_MAX) { ast::ident_free(ident: ast::ident); - return syntaxerr(lex::mkloc(lexer), - "Identifier exceeds maximum length"); + return syntaxerr(loc, "Identifier exceeds maximum length"); }; return (ident: ast::ident, trailing); };