heyman / heynote

A dedicated scratchpad for developers
https://heynote.com
Other
4.01k stars 200 forks source link

Bug: Subtraction of two numbers no value in result #159

Closed tomer-ben-david closed 9 months ago

tomer-ben-david commented 9 months ago

Describe the bug I subtracted one variable from another in math block and don't see the answer.

To Reproduce Create a new math block and put this in:

start = 1673546301 end = 1673627599

t = end − start

t will have no result value.

Expected behavior t will have the result value of the subtraction.

Screenshots ScreenShot 2024-01-12 at 07 54 49@2x

Desktop (please complete the following information): MacOs Version 1.6.0

Additional context Add any other context about the problem here.

heyman commented 9 months ago

That's partly because end is a reserved keyword in Math.js, I believe. The following works:

start = 1673546301
end_ = 1673627599
end_ - start

And I think that it doesn't work in your screenshot (where you use startDate and endDate) because the minus isn't actually a minus sign but an en-dash or em-dash.


It would be nice to have a Lezer grammar for the Math.js syntax to have syntax highlighting for reserved keywords and constants. In this case, end would then have been highlighted, and it would have been easier to understand what was going on.

heyman commented 9 months ago

It would be nice to have a Lezer grammar for the Math.js syntax to have syntax highlighting for reserved keywords and constants

Created an issue for that here: #160