Browse Source

[js] emit an error on missing args for js.Syntax.code()
closes #8892

Aleksandr Kuzmenko 5 years ago
parent
commit
68f6e0face

+ 2 - 5
src/generators/genjs.ml

@@ -962,11 +962,8 @@ and gen_syntax ctx meth args pos =
 		in
 		begin
 			match args with
-			| [] ->
-				if code = "this" then
-					spr ctx (this ctx)
-				else
-					spr ctx (String.concat "\n" (ExtString.String.nsplit code "\r\n"))
+			| [] when code = "this" ->
+				spr ctx (this ctx)
 			| _ ->
 				Codegen.interpolate_code ctx.com code args (spr ctx) (gen_value ctx) code_pos
 		end

+ 5 - 0
tests/misc/projects/Issue8892/Main.hx

@@ -0,0 +1,5 @@
+class Main {
+	static function main() {
+		js.Syntax.code('{0}');
+	}
+}

+ 2 - 0
tests/misc/projects/Issue8892/compile-fail.hxml

@@ -0,0 +1,2 @@
+-main Main
+-js bin/test.js

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

@@ -0,0 +1 @@
+Main.hx:3: characters 19-22 : Out-of-bounds special parameter: 0