Merge pull request #15912 from s-hadinger/berry_fix_lexer_side_effect

Fix Berry lexer regression
This commit is contained in:
s-hadinger 2022-07-02 16:13:57 +02:00 committed by GitHub
commit 10a9a191ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -336,7 +336,11 @@ static btokentype scan_decimal(blexer *lexer)
{
btokentype type = TokenInteger;
match(lexer, is_digit);
if (decimal_dots(lexer) || scan_realexp(lexer)) {
/* decimal_dots() and scan_realexp() have side effect, so we call each explicitly */
/* to prevent binary shortcut if the first is true */
bbool has_decimal_dots = decimal_dots(lexer);
bbool is_realexp = scan_realexp(lexer);
if (has_decimal_dots || is_realexp) {
type = TokenReal;
}
lexer->buf.s[lexer->buf.len] = '\0';