浏览代码

really don't hit the analyzer in display mode

I mean it
Simon Krajewski 9 年之前
父节点
当前提交
4eb7145e52
共有 1 个文件被更改,包括 17 次插入12 次删除
  1. 17 12
      src/typing/typeload.ml

+ 17 - 12
src/typing/typeload.ml

@@ -2215,18 +2215,23 @@ module ClassInitializer = struct
 						(* disallow initialization of non-physical fields (issue #1958) *)
 						display_error ctx "This field cannot be initialized because it is not a real variable" p; e
 					| Var v when not fctx.is_static ->
-						let e = match Optimizer.make_constant_expression ctx (maybe_run_analyzer e) with
-							| Some e -> e
-							| None ->
-								let rec has_this e = match e.eexpr with
-									| TConst TThis ->
-										display_error ctx "Cannot access this or other member field in variable initialization" e.epos;
-									| TLocal v when (match ctx.vthis with Some v2 -> v == v2 | None -> false) ->
-										display_error ctx "Cannot access this or other member field in variable initialization" e.epos;
-									| _ ->
-									Type.iter has_this e
-								in
-								has_this e;
+						let e = match ctx.com.display with
+							| DMNone ->
+								begin match Optimizer.make_constant_expression ctx (maybe_run_analyzer e) with
+									| Some e -> e
+									| None ->
+										let rec has_this e = match e.eexpr with
+											| TConst TThis ->
+												display_error ctx "Cannot access this or other member field in variable initialization" e.epos;
+											| TLocal v when (match ctx.vthis with Some v2 -> v == v2 | None -> false) ->
+												display_error ctx "Cannot access this or other member field in variable initialization" e.epos;
+											| _ ->
+											Type.iter has_this e
+										in
+										has_this e;
+										e
+								end
+							| _ ->
 								e
 						in
 						e