Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Map and Set don't work with concatenated strings #583

Closed
cleiner opened this issue Jul 17, 2019 · 1 comment
Closed

Map and Set don't work with concatenated strings #583

cleiner opened this issue Jul 17, 2019 · 1 comment

Comments

@cleiner
Copy link

cleiner commented Jul 17, 2019

I have been trying to run some third-party code on Rhino 1.7.11 and noticed that Map and Set don't always behave as expected. Here are two test cases to reproduce the issue:

  var myMap = new Map([['key1', 'value1'], ['key2', 17]]);
  for(let i = 1; i <= myMap.size; i++) {
    let key = 'key' + i;
    print(myMap.get(key));
  }

Expected output: value1, 17 | Actual output: undefined, undefined

var mySet = new Set(['word1', 'word2']);
for(let i = 0; i <= mySet.size; i++) {
  let value = 'word' + i;
  print(mySet.has(value));
}

Expected output: false, true, true | Actual output: false, false, false

Due to the string concatenation, Rhino passes a ConsString instance to the NativeMap/NativeSet methods which is of course not equal to the String that was added to the collection initially.

Unlike #247 and #496 there's no obvious or intentional Java-interop here, so I hope this warrants a separate issue.

@rbri
Copy link
Collaborator

rbri commented Jul 18, 2019

Will try to fix that

@gbrail gbrail closed this as completed in a27fac1 Jul 24, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants