Procházet zdrojové kódy

[lua] fix issue 5945

Justin Donaldson před 8 roky
rodič
revize
563f1cf3c6

+ 3 - 1
std/lua/_std/haxe/ds/StringMap.hx

@@ -28,6 +28,8 @@ class StringMap<T> implements haxe.Constraints.IMap<String,T> {
 	private var v : Dynamic; // Values table
 
 	public inline function new() : Void {
+		// these need to be plain anonymous tables,
+		// so that we can set arbitrary string values.
 		v = untyped __lua__("{}");
 		k = untyped __lua__("{}");
 	}
@@ -42,7 +44,7 @@ class StringMap<T> implements haxe.Constraints.IMap<String,T> {
 	}
 
 	public inline function exists( key : String ) : Bool untyped {
-		return untyped __lua__("{0}[{1}] or false", k, key);
+		return untyped __lua__("({0}[{1}] or false)", k, key);
 	}
 
 	public function remove( key : String ) : Bool untyped {

+ 11 - 0
tests/unit/src/unit/issues/Issue5945.hx

@@ -0,0 +1,11 @@
+package unit.issues;
+
+import haxe.ds.StringMap;
+class Issue5945 extends Test {
+	function test() {
+		var test_map : StringMap<String> = new StringMap<String>();
+		var test_key : String = "key";
+		test_map.set(test_key, "Hello world");
+		eq(test_map.exists(test_key) == false, false);
+	}
+}