hare

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

commit da23ff58f3971c73c29d3f719c59631f89890221
parent 7e8a3466c36d1d53856f85e59d5f503eec1a6943
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date:   Thu, 24 Feb 2022 01:54:12 +0100

hare::parse: don't abort in want(..., ltok::NAME)

want(..., ltok::NAME) was triggering a type assertion in lex::tokstr
when composing the error message

Signed-off-by: Bor Grošelj Simić <bor.groseljsimic@telemach.net>

Diffstat:
Mhare/parse/parse.ha | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hare/parse/parse.ha b/hare/parse/parse.ha @@ -41,7 +41,8 @@ fn want(lexer: *lex::lexer, want: lex::ltok...) (lex::token | error) = { let buf = strio::dynamic(); defer io::close(&buf); for (let i = 0z; i < len(want); i += 1) { - const tstr = lex::tokstr((want[i], void, lex::mkloc(lexer))); + const tstr = if (want[i] == ltok::NAME) "name" + else lex::tokstr((want[i], void, lex::mkloc(lexer))); fmt::fprintf(&buf, "'{}'", tstr)!; if (i + 1 < len(want)) { fmt::fprint(&buf, ", ")!;