Browse Source

fix ocaml exception on Socket.connect() in a macro (fixes #8336)

Aleksandr Kuzmenko 6 năm trước cách đây
mục cha
commit
134133d53f

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

@@ -1976,7 +1976,7 @@ module StdSocket = struct
 		let this = this vthis in
 		let host = decode_i32 host in
 		let port = decode_int port in
-		catch_unix_error Unix.connect this (ADDR_INET (StdHost.int32_addr host,port));
+		catch_unix_error (Unix.connect this) (ADDR_INET (StdHost.int32_addr host,port));
 		vnull
 	)
 

+ 16 - 0
tests/misc/projects/Issue8336/Main.hx

@@ -0,0 +1,16 @@
+class Main {
+	public static function main() {
+		#if !macro
+		connect();
+		#end
+	}
+
+	macro static function connect() {
+		try {
+			new sys.net.Socket().connect(new sys.net.Host("192.168.0.66"), 443);
+		} catch(e:String) {
+			haxe.macro.Context.error(e, (macro {}).pos);
+		}
+		return macro {}
+	}
+}

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

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

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

@@ -0,0 +1 @@
+Main.hx:12: characters 39-41 : No route to host(connect, )