Browse Source

[eval] fix Sys.programPath() if -main is not specified
(fixes #8466)

Aleksandr Kuzmenko 6 years ago
parent
commit
aa17f2a963

+ 2 - 2
src/macro/eval/evalStdLib.ml

@@ -2561,11 +2561,11 @@ module StdSys = struct
 		let ctx = get_ctx() in
 		let ctx = get_ctx() in
 		let com = ctx.curapi.get_com() in
 		let com = ctx.curapi.get_com() in
 		match com.main_class with
 		match com.main_class with
-		| None -> assert false
+		| None -> vnull
 		| Some p ->
 		| Some p ->
 			match ctx.curapi.get_type (s_type_path p) with
 			match ctx.curapi.get_type (s_type_path p) with
 			| Some(Type.TInst (c, _)) -> create_unknown (Extc.get_full_path c.Type.cl_pos.Globals.pfile)
 			| Some(Type.TInst (c, _)) -> create_unknown (Extc.get_full_path c.Type.cl_pos.Globals.pfile)
-			| _ -> assert false
+			| _ -> vnull
 	)
 	)
 
 
 	let putEnv = vfun2 (fun s v ->
 	let putEnv = vfun2 (fun s v ->

+ 7 - 0
tests/misc/projects/Issue8466/Main.hx

@@ -0,0 +1,7 @@
+class Main {
+	static public function init() {
+		if(Sys.programPath() != null) {
+			throw 'Unexpected value';
+		}
+	}
+}

+ 1 - 0
tests/misc/projects/Issue8466/compile.hxml

@@ -0,0 +1 @@
+--macro Main.init()