Browse Source

Fix missing field generation (#12240)

RblSb 2 months ago
parent
commit
b7eaead91b
2 changed files with 16 additions and 2 deletions
  1. 11 1
      src/context/display/displayFields.ml
  2. 5 1
      tests/display/src/cases/Issue10713.hx

+ 11 - 1
src/context/display/displayFields.ml

@@ -358,7 +358,17 @@ let collect ctx e_ast e dk with_type p =
 let handle_missing_field_raise ctx tthis i mode with_type pfield =
 	let tret = match with_type with
 		| WithType.WithType(t,_) -> t
-		| WithType.Value _ -> mk_mono()
+		| WithType.Value _ ->
+			begin match mode with
+				| MSet (Some e) ->
+					begin try
+						let e = type_expr ctx e WithType.value in
+						e.etype
+					with _ ->
+						mk_mono()
+					end
+				| _ -> mk_mono()
+			end
 		| WithType.NoValue ->
 			match mode with
 			| MCall _ -> ctx.t.tvoid

+ 5 - 1
tests/display/src/cases/Issue10713.hx

@@ -17,6 +17,10 @@ class Issue10713 extends DisplayTestCase {
 	function test() {
 		var d = diagnostics();
 		var range = diagnosticsRange(pos(1), pos(2));
-		utest.Assert.isTrue(d.exists(d -> d.kind == MissingFields && utest.Assert.same(d.range, range)));
+		final item = d.find(d -> d.kind == MissingFields && utest.Assert.same(d.range, range));
+		utest.Assert.isTrue(item != null);
+		final args:MissingFieldDiagnostics = item.args;
+		final field:MissingField = args.entries[0].fields[0];
+		utest.Assert.isTrue(field.type.args.path.typeName == "Int");
 	}
 }