Skip to content
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

Numeric functions shouldn't return NaN #539

Closed
cmontella opened this issue Nov 12, 2016 · 3 comments
Closed

Numeric functions shouldn't return NaN #539

cmontella opened this issue Nov 12, 2016 · 3 comments
Assignees

Comments

@cmontella
Copy link
Contributor

A function that would return NaN should instead return no results.

@Cormac-Williams
Copy link
Contributor

Cormac-Williams commented Nov 12, 2016

But the question becomes then, how does Eve allow the detection of out of range function use?

Or equally, how does Eve handle divide by zero?

At the moment, whatever the result that comes out of Javascript is republished. This I agree is probably an issue. But I am unsure whether filtering the result is the correct form.

@Cormac-Williams
Copy link
Contributor

Cormac-Williams commented Nov 13, 2016

I got curious so had a play. This push
Cormac-Williams@8716ca1 appears to do what you wish, I essentially emulated what is already present in Logical.ts. Let me know if it works for you and I'll make it a formal pull request.

This code now would not run

search
div = 1 / 0
value = "Works"
bind @view
[#value value:"{{value}}"]

But this code runs correctly

search
a = 1
b = 0
value = if not( a / b ) then
"Ooops, divide by zero?" else
a / b
bind @view
[#value value:"{{value}}"]

So code written carelessly in terms of a divisor or testing for NaN is more than likely going to filter, but still leaving the possibility open of a more nuanced examination if necessary.

//Edit. Don't use the above commit. It causes issues for other uses of operators.

@joshuafcole
Copy link
Contributor

This has been in since 0.2.2, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants