-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
between/clamp bug with negative numbers #383
Milestone
Comments
Yes, the prefix operator needs it's priority to be bumped. Thanks for
finding this out!
I assume (-10).between(...) will work as a temporary workaround
…On Tue, Jul 28, 2020, 1:13 PM Adrian Ho ***@***.***> wrote:
> -10.between(-50, -1)
ERROR: unknown operator: -BOOLEAN
[1:1] -10.between(-50, -1)
> -10.clamp(-50, -1)
1
Parser issue?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#383>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACQFZDSZ3WSI5LZXK4KE3LR52JDXANCNFSM4PKJZANA>
.
|
👍, parenthesizing the negative number object gives correct results for all the math operations in both my PRs. |
odino
added a commit
that referenced
this issue
Jul 28, 2020
This bugfix introduces negative numbers into our parser: before, -10 would be parsed as (minus, number) whereas right now it's going to be parsed as (number) only. This fixes a bug with precedences, where `-1.str()` would be parsed as (-, (1, str)), leading to first calling the str method on the positive number, then applying the minus. Before: ``` ⧐ -1.234.str() ERROR: unknown operator: -STRING [1:1] -1.234.str() ``` After: ``` ⧐ -1.234.str() -1.234 ``` If a space is found between the minus and the number, the old parsing mechanism still applies. I found inspiration in Ruby, where: ``` $ - 1.to_s() -@: undefined method `-@' for "1":String $-1.to_s() -1 $ -10.3.floor() -11 $ - 10.3.floor() -10 ```
odino
added a commit
that referenced
this issue
Jul 28, 2020
This bugfix introduces negative numbers into our parser: before, -10 would be parsed as (minus, number) whereas right now it's going to be parsed as (number) only. This fixes a bug with precedences, where `-1.str()` would be parsed as (-, (1, str)), leading to first calling the str method on the positive number, then applying the minus. Before: ``` ⧐ -1.234.str() ERROR: unknown operator: -STRING [1:1] -1.234.str() ``` After: ``` ⧐ -1.234.str() -1.234 ``` If a space is found between the minus and the number, the old parsing mechanism still applies. I found inspiration in Ruby, where: ``` $ - 1.to_s() -@: undefined method `-@' for "1":String $-1.to_s() -1 $ -10.3.floor() -11 $ - 10.3.floor() -10 ```
odino
added a commit
that referenced
this issue
Jul 28, 2020
This bugfix introduces negative numbers into our parser: before, -10 would be parsed as (minus, number) whereas right now it's going to be parsed as (number) only. This fixes a bug with precedences, where `-1.str()` would be parsed as (-, (1, str)), leading to first calling the str method on the positive number, then applying the minus. Before: ``` ⧐ -1.234.str() ERROR: unknown operator: -STRING [1:1] -1.234.str() ``` After: ``` ⧐ -1.234.str() -1.234 ``` If a space is found between the minus and the number, the old parsing mechanism still applies. I found inspiration in Ruby, where: ``` $ - 1.to_s() -@: undefined method `-@' for "1":String $-1.to_s() -1 $ -10.3.floor() -11 $ - 10.3.floor() -10 ```
odino
added a commit
that referenced
this issue
Jul 28, 2020
This bugfix introduces negative numbers into our parser: before, -10 would be parsed as (minus, number) whereas right now it's going to be parsed as (number) only. This fixes a bug with precedences, where `-1.str()` would be parsed as (-, (1, str)), leading to first calling the str method on the positive number, then applying the minus. Before: ``` ⧐ -1.234.str() ERROR: unknown operator: -STRING [1:1] -1.234.str() ``` After: ``` ⧐ -1.234.str() -1.234 ``` If a space is found between the minus and the number, the old parsing mechanism still applies. I found inspiration in Ruby, where: ``` $ - 1.to_s() -@: undefined method `-@' for "1":String $-1.to_s() -1 $ -10.3.floor() -11 $ - 10.3.floor() -10 ```
odino
added a commit
that referenced
this issue
Jul 28, 2020
This bugfix introduces negative numbers into our parser: before, -10 would be parsed as (minus, number) whereas right now it's going to be parsed as (number) only. This fixes a bug with precedences, where `-1.str()` would be parsed as (-, (1, str)), leading to first calling the str method on the positive number, then applying the minus. Before: ``` ⧐ -1.234.str() ERROR: unknown operator: -STRING [1:1] -1.234.str() ``` After: ``` ⧐ -1.234.str() -1.234 ``` If a space is found between the minus and the number, the old parsing mechanism still applies. I found inspiration in Ruby, where: ``` $ - 1.to_s() -@: undefined method `-@' for "1":String $-1.to_s() -1 $ -10.3.floor() -11 $ - 10.3.floor() -10 ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Parser issue?
The text was updated successfully, but these errors were encountered: