feat: add containsKey method to Map and validate key types in subscript operations

Implement `containsKey()` native method on Map that returns a boolean indicating whether the given key exists in the map. Add `validateKey()` helper to reject non-value-type keys (objects, lists, fibers, etc.) with a clear runtime error. Refactor `wrenMapGet()` signature to return success/failure via bool and output the value through an out-parameter, enabling both `containsKey()` and the existing subscript operator to share the same key validation and lookup logic. Update `map_subscript` to return `null` instead of crashing when a key is not found. Add test cases for `containsKey` success/failure, and runtime error tests for invalid key types in subscript getter, setter, and containsKey.
This commit is contained in:
Bob Nystrom
2015-01-25 20:39:19 +00:00
parent 1d195f13ea
commit a83205ef89
8 changed files with 65 additions and 10 deletions
+1
View File
@@ -0,0 +1 @@
var result = {}.containsKey([]) // expect runtime error: Key must be a value type.