Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

map insert produces duplicate keys #606

Open
Defelo opened this issue Nov 21, 2024 · 4 comments
Open

map insert produces duplicate keys #606

Defelo opened this issue Nov 21, 2024 · 4 comments

Comments

@Defelo
Copy link
Contributor

Defelo commented Nov 21, 2024

This does not seem to happen on Uiua Pad, but at least in the native interpreter on x86_64-linux (commit 743ec31).

Example:

map {"x" "y" "z"} [1 2 3]
remove □"y"
insert □"z" 4 .
⟜°map .
⍣(insert □"a" 17|◌)

Output:

╭─
  ⌜x⌟ → 1
  ⌜z⌟ → 3
          ╯
╭─
  ⌜x⌟ → 1
  ⌜z⌟ → 4
  ⌜z⌟ → 4
          ╯
[1 4]
{"x" "z" "z"}
"test.ua:5:3: Cannot insert into map with 3 keys and 2 value(s)"
@Defelo
Copy link
Contributor Author

Defelo commented Nov 22, 2024

Hi @kaikalii, thanks for taking a look at this so quickly! While this specific test case now seems to work, I unfortunately found some more problems:

map [0 0 1] [1 2 3]
°map

Output:

[1 2 3]
[0 1]

So again, we have a map where the number of keys and values differ and thus inserting and removing fail.

Apart from that I also found a second (larger) test case which starts with a valid map and breaks it using remove and insert:

{"hlvq" "xvng" "tv" "sgnr" "rdnp" "bxlh" "ktcxx" "jg" "fm" "lxccq" "fnztg" "zsp" "cc" "vbl" "dk" "tsrjk" "xrzx" "zh" "qvq" "dp" "sh" "jfvnl" "lq" "nnnrz" "zzl" "kmsq"}
map ⟜(⇡⧻)
remove "zh"
insert "kmsq" 0
∩⧻°map

Output:

25
26

In this case the key "kmsq" is duplicated, so now we have a map with 26 keys but only 25 values.

(tested on commit 3bf1ff3)

@kaikalii
Copy link
Member

This should be fixed in 0fce8a1.
Let me know if you find any others!

@Defelo
Copy link
Contributor Author

Defelo commented Nov 22, 2024

@kaikalii I think I found another one. This time the program doesn't terminate at all (which unfortunately also causes the vscode extension to not respond anymore):

map {"a" "b" "c"} [1 2 3]
remove "b"
insert "d" 4
insert "e" 42

@kaikalii kaikalii reopened this Nov 22, 2024
@kaikalii
Copy link
Member

Fixed in 156d82b.
I'm going to leave this issue open for a while just in case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants