Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
(fix) Wrong JS code generation for infinity/nan
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
  • Loading branch information
jeromesimeon committed Apr 30, 2019
1 parent 5f61880 commit 0b90adf
Show file tree
Hide file tree
Showing 6 changed files with 6,909 additions and 6,901 deletions.
2 changes: 2 additions & 0 deletions examples/smoke/logic.ergo
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ contract Smoke over TemplateModel {
enforce(some(A{ a : 1 })?.a ?? 2 = 1);
enforce(C{ contract : "foo" }.contract = "foo");
enforce(C{ contract : "foo" }.contract = "foo");
enforce(infinity = 1.0/0.0);
enforce(-infinity = -1.0/0.0);
enforce("\"\\
" = "\034\092\010\013\009");
enforce("\"\\
Expand Down
6 changes: 5 additions & 1 deletion mechanization/Utils/EJSON.v
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ Section EJSON.
Fixpoint ejsonToJS (quotel:string) (j : ejson) : estring
:= match j with
| ejnull => `"null" (* to be discussed *)
| ejnumber n => `to_string n
| ejnumber n =>
if (float_eq n float_infinity) then `"Infinity"
else if (float_eq n float_neg_infinity) then `"-Infinity"
else if (float_eq n float_nan) then `"NaN"
else `to_string n
| ejbool b => if b then `"true" else `"false"
| ejstring s => stringToJS quotel s
| ejarray ls =>
Expand Down
Loading

0 comments on commit 0b90adf

Please sign in to comment.