Browse Source

fix typo suggestions for abstract enum constructors (closes #5833)

Simon Krajewski 8 years ago
parent
commit
e90c38cc1f

+ 4 - 1
src/typing/typer.ml

@@ -4026,7 +4026,10 @@ and maybe_type_against_enum ctx f with_type p =
 				| TEnum (en,_) ->
 				| TEnum (en,_) ->
 					en.e_path,en.e_names,TEnumDecl en
 					en.e_path,en.e_names,TEnumDecl en
 				| TAbstract ({a_impl = Some c} as a,_) when has_meta Meta.Enum a.a_meta ->
 				| TAbstract ({a_impl = Some c} as a,_) when has_meta Meta.Enum a.a_meta ->
-					a.a_path,List.map (fun cf -> cf.cf_name) c.cl_ordered_fields,TAbstractDecl a
+					let fields = ExtList.List.filter_map (fun cf ->
+						if Meta.has Meta.Enum cf.cf_meta then Some cf.cf_name else None
+					) c.cl_ordered_statics in
+					a.a_path,fields,TAbstractDecl a
 				| TAbstract (a,pl) when not (Meta.has Meta.CoreType a.a_meta) ->
 				| TAbstract (a,pl) when not (Meta.has Meta.CoreType a.a_meta) ->
 					begin match get_abstract_froms a pl with
 					begin match get_abstract_froms a pl with
 						| [t2] ->
 						| [t2] ->

+ 9 - 0
tests/misc/projects/Issue5833/Main.hx

@@ -0,0 +1,9 @@
+@:enum abstract A(Int) {
+	var Typo = 0;
+}
+
+class Main {
+	static public function main() {
+		var a:A = Typi;
+	}
+}

+ 3 - 0
tests/misc/projects/Issue5833/compile-fail.hxml

@@ -0,0 +1,3 @@
+-main Main
+--no-output
+-js js.js

+ 1 - 0
tests/misc/projects/Issue5833/compile-fail.hxml.stderr

@@ -0,0 +1 @@
+Main.hx:7: characters 12-16 : Identifier 'Typi' is not part of A (Suggestion: Typo)