Commit Graph

2 Commits

Author SHA1 Message Date
Evan Shaw
0526cee655 fix: stop lexing negative numbers as single tokens to fix parsing of subtraction
Previously, the lexer greedily consumed a `-` followed by a digit as a single negative number token, causing "1 -1" to be lexed as two number tokens instead of a minus operator and a positive literal. This broke parsing of subtraction expressions without spaces.

Now `-` always emits a TOKEN_MINUS, and the parser handles unary negation. This is a breaking change: `-16.sqrt` is now parsed as `-(16.sqrt)` instead of `(-16).sqrt`, requiring parentheses for negative method receivers. All number method tests (abs, ceil, floor, sqrt, toString) are updated to use explicit parentheses for negative receivers.
2015-01-09 07:06:50 +00:00
Bob Nystrom
193e4e30ab feat: add ceil, cos, sin, sqrt, isNan native methods and division-by-zero tests
Implement five new Num methods (ceil, cos, sin, sqrt, isNan) in wren_core.c and register them on the Num class. Add corresponding test files for ceil, floor, is_nan, and sqrt. Extend divide.wren with division-by-zero edge cases (inf, -inf, nan). Remove stale TODO comments from minus, multiply, and plus tests.
2014-01-08 15:47:14 +00:00