diff --git a/src/syntax/parser.mly b/src/syntax/parser.mly index b745705aeaf..21f47919c16 100644 --- a/src/syntax/parser.mly +++ b/src/syntax/parser.mly @@ -183,7 +183,8 @@ let reify in_macro = | Regexp (r,o) -> mk_enum "Constant" "CRegexp" [(EConst (String r),p);(EConst (String o),p)] p in let rec to_binop o p = - let op n = mk_enum "Binop" n [] p in + let pmin = {p with pmax = p.pmin} in + let op n = mk_enum "Binop" n [] pmin in match o with | OpAdd -> op "OpAdd" | OpMult -> op "OpMult" diff --git a/tests/display/src/cases/Issue6396.hx b/tests/display/src/cases/Issue6396.hx index 4c8ba359f8c..cc4eec1c177 100644 --- a/tests/display/src/cases/Issue6396.hx +++ b/tests/display/src/cases/Issue6396.hx @@ -14,7 +14,7 @@ class Issue6396 extends DisplayTestCase { } **/ function test() { - eq(range(1, 2), position(pos(2))); - eq("String", type(pos(2))); + eq(range(1, 2), position(pos(3))); + eq("String", type(pos(3))); } } diff --git a/tests/display/src/cases/Issue6399.hx b/tests/display/src/cases/Issue6399.hx new file mode 100644 index 00000000000..22fa49dc01a --- /dev/null +++ b/tests/display/src/cases/Issue6399.hx @@ -0,0 +1,29 @@ +package cases; + +class Issue6399 extends DisplayTestCase { + /** + class Main { + public static function main() {} + + macro function foo({-1-}name{-2-}:String, {-3-}struct{-4-}:Expr, {-5-}defaults{-6-}:Expr) { + return macro { + if ($str{-7-}uct.$n{-8-}ame == null) $str{-9-}uct.$n{-10-}ame = $defa{-11-}ults.$n{-12-}ame; + } + } + } + **/ + function test() { + for (i in [8, 10, 12]) { + eq(range(1, 2), position(pos(i))); + eq("String", type(pos(i))); + } + + for (i in [7, 9]) { + eq(range(3, 4), position(pos(i))); + eq("Dynamic", type(pos(i))); + } + + eq(range(5, 6), position(pos(11))); + eq("Dynamic", type(pos(11))); + } +}