Skip to content

StringMap bug when using an emoji string parsed from JSON in C++ backend #1375

Description

@singpolyma
import haxe.Json;
import haxe.ds.StringMap;

class ReproEmojiStringMap {
	static function dump(label:String, s:String) {
		trace(label, s, s.length, [for (i in 0...s.length) s.charCodeAt(i)]);
	}

	static function main() {
		// Get the same string from json and a literal
		var fromJson:String = cast Json.parse("\"\\ud83d\\udc4d\"");
		var literal = "👍";

		// confirm they are the same string
		dump("fromJson", fromJson);
		dump("literal", literal);
		trace("equal", fromJson == literal);

		// Set a StringMap key using the one from JSON
		var m = new StringMap<Int>();
		m.set(fromJson, 1);

		// Observe that the identical string literal does not work to look up this key
		trace("exists(fromJson)", m.exists(fromJson));
		trace("exists(literal)", m.exists(literal));
		trace("get(fromJson)", m.get(fromJson));
		trace("get(literal)", m.get(literal));
	}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions