Skip to content

Commit

Permalink
[typer] cast inline vars to field type if it is different from the ex…
Browse files Browse the repository at this point in the history
…pression

closes #7132
  • Loading branch information
Simn committed Jun 6, 2018
1 parent 7a73e4c commit 12ef7f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/typing/calls.ml
Expand Up @@ -501,7 +501,8 @@ let rec acc_get ctx g p =
let rec loop e = Type.map_expr loop { e with epos = p } in
let e = loop e in
let e = Optimizer.inline_metadata e f.cf_meta in
e
if not (type_iseq f.cf_type e.etype) then mk (TCast(e,None)) f.cf_type e.epos
else e
end
| AKMacro _ ->
assert false
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/src/unit/issues/Issue7132.hx
@@ -0,0 +1,9 @@
package unit.issues;

class Issue7132 extends unit.Test {
static inline var x:Float = 20;

function test() {
HelperMacros.typedAs(x, 0.);
}
}

0 comments on commit 12ef7f7

Please sign in to comment.