Browse Source

[typer] fail properly if abstract is referenced in argument defaults

closes #10186
Simon Krajewski 4 years ago
parent
commit
d061118db2

+ 1 - 1
src/typing/typerBase.ml

@@ -55,7 +55,7 @@ let get_this ctx p =
 		in
 		mk (TLocal v) ctx.tthis p
 	| FunMemberAbstract ->
-		let v = (try PMap.find "this" ctx.locals with Not_found -> die "" __LOC__) in
+		let v = (try PMap.find "this" ctx.locals with Not_found -> error "Cannot reference this abstract here" p) in
 		mk (TLocal v) v.v_type p
 	| FunConstructor | FunMember ->
 		mk (TConst TThis) ctx.tthis p

+ 6 - 0
tests/misc/projects/Issue10186/Main.hx

@@ -0,0 +1,6 @@
+abstract Main(Dynamic) {
+	static function main() {}
+	var bar(get, never):Int;
+	public function foo(?v = bar) {}
+	function get_bar() return 1;
+}

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

@@ -0,0 +1 @@
+--main Main

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

@@ -0,0 +1 @@
+Main.hx:4: characters 27-30 : Cannot reference this abstract here