Parser: Hint for the mod function when parsing %

Was reported several times:
 - https://github.com/slint-ui/slint/discussions/4190
 - https://github.com/slint-ui/slint/issues/3980
This commit is contained in:
Olivier Goffart 2023-12-19 16:03:53 +01:00
parent 2404cce0bc
commit 2ce161ced8
2 changed files with 18 additions and 0 deletions

View file

@ -134,6 +134,12 @@ fn parse_expression_helper(p: &mut impl Parser, precedence: OperatorPrecedence)
parse_expression_helper(&mut *p, OperatorPrecedence::Mul);
}
if p.nth(0).kind() == SyntaxKind::Percent {
p.error("Unexpected '%'. For the unit, it should be attached to the number. If you're looking for the modulo operator, use the 'Math.mod(x, y)' function");
p.consume();
return false;
}
if precedence >= OperatorPrecedence::Add {
return true;
}