2
0
Эх сурвалжийг харах

[typer] don't run analyzer early on member init expressions

closes #10335
Simon Krajewski 3 жил өмнө
parent
commit
a6ecfb5d92

+ 0 - 5
src/typing/typeloadFields.ml

@@ -853,11 +853,6 @@ module TypeBinding = struct
 					let e = if ctx.com.display.dms_display && ctx.com.display.dms_error_policy <> EPCollect then
 						e
 					else begin
-						let e = Optimizer.reduce_loop ctx (maybe_run_analyzer e) in
-						let e = (match Optimizer.make_constant_expression ctx e with
-							| Some e -> e
-							| None -> e
-						) in
 						let rec check_this e = match e.eexpr with
 							| TConst TThis ->
 								display_error ctx "Cannot access this or other member field in variable initialization" e.epos;

+ 22 - 0
tests/unit/src/unit/issues/Issue10335.hx

@@ -0,0 +1,22 @@
+package unit.issues;
+
+private class NotMain {
+	public final prop = {
+		var testvalue = 1;
+		{
+			get: () -> testvalue,
+			set: v -> testvalue = v,
+		}
+	}
+
+	public function new() {}
+}
+
+class Issue10335 extends unit.Test {
+	function test() {
+		final inst = new NotMain();
+		eq(1, inst.prop.get());
+		inst.prop.set(2);
+		eq(2, inst.prop.get());
+	}
+}