diff --git a/Test.hx b/Test.hx index 42c306f..fb0b394 100644 --- a/Test.hx +++ b/Test.hx @@ -73,6 +73,8 @@ class Test { test("{ x = 3; x; }", 3); test("{ x : 3, y : {} }.x", 3); test("function bug(){ \n }\nbug().x", null); + test("1 + 2 == 3", true); + test("-2 == 3 - 5", true); trace("Done"); } diff --git a/hscript/Macro.hx b/hscript/Macro.hx index d9e3230..f445dcb 100644 --- a/hscript/Macro.hx +++ b/hscript/Macro.hx @@ -198,6 +198,8 @@ class Macro { for( f in fields ) tf.push( { field : f.name, expr : convert(f.e) } ); EObjectDecl(tf); + case ETernary(cond, e1, e2): + ETernary(convert(cond), convert(e1), convert(e2)); }, pos : #if hscriptPos { file : p.file, min : e.pmin, max : e.pmax } #else p #end } } diff --git a/hscript/Parser.hx b/hscript/Parser.hx index 9aa3196..91ef2fb 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -355,7 +355,7 @@ class Parser { function makeUnop( op, e ) { return switch( expr(e) ) { case EBinop(bop, e1, e2): mk(EBinop(bop, makeUnop(op, e1), e2), pmin(e1), pmax(e2)); - case ETernary(e1,e2,e3): mk(ETernary(makeUnop(op,e1),e2,e3),pmin(e1) + case ETernary(e1, e2, e3): mk(ETernary(makeUnop(op, e1), e2, e3), pmin(e1), pmax(e3)); default: mk(EUnop(op,true,e),pmin(e),pmax(e)); } }