Skip to content

Return errors instead of panicking on unhashable map keys - #369

Merged
mattn merged 1 commit into
masterfrom
fix-unhashable-map-key-panic
Jul 9, 2026
Merged

Return errors instead of panicking on unhashable map keys#369
mattn merged 1 commit into
masterfrom
fix-unhashable-map-key-panic

Conversation

@mattn

@mattn mattn commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Using a slice or map as a map key crashed the host program with an uncaught reflect panic in four places: map literals, map index assignment, map index read, and delete.

  • {[1,2]: 3}
  • a = {}; a[[1,2]] = 3
  • a = {}; a[[1,2]]
  • delete(m, [1,2])

Writes and deletes now return a VM error; reads return nil, matching the existing behavior for keys whose type cannot be converted. A nil key remains valid, as in Go.

@mattn
mattn merged commit 387f4ec into master Jul 9, 2026
12 checks passed
@mattn
mattn deleted the fix-unhashable-map-key-panic branch July 10, 2026 00:43
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

Successfully merging this pull request may close these issues.

1 participant