Skip to content

fix: resolve Map.containsKey as an alias for contains - #20

Merged
zombocoder merged 1 commit into
zombocoder:mainfrom
Craftegy-NextGen:fix/map-containskey-resolution
Oct 27, 2026
Merged

zombocoder merged 1 commit into
zombocoder:mainfrom
Craftegy-NextGen:fix/map-containskey-resolution

Conversation

@sashml

@sashml sashml commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Map dispatches contains(key) and containsValue(value), but not containsKey(key). Code written
against the familiar Java-style Map API therefore fails at runtime with
Unknown method 'containsKey' on Map type.

Fix

Accept containsKey as an alias for contains in the Map method dispatch, pairing it with the
existing containsValue. The argument-count error now names the method that was actually called.
Purely additive.

Tests

  • Runnable example examples/test_map_containskey.obq: containsKey and contains agree on present
    and missing keys.

Verification

  • Windows 10, MSVC 2022, Release, Ninja, GoogleTest from vcpkg: build OK, o2l_tests 509/509 passing; the
    example passes.
  • Linux and macOS: covered by CI.

The interpreter only dispatched Map.contains(), so code written against
the Java-style Map API raised "Unknown method 'containsKey' on Map type"
at runtime. Add containsKey as an alias for contains in the Map method
dispatch; it pairs with the already-present containsValue, so callers can
use either spelling. The argument-count error now reports the method name
used.

Adds a runnable regression example (examples/test_map_containskey.obq).

Signed-off-by: svaiml <88979468+svaiml@users.noreply.github.com>
@zombocoder
zombocoder merged commit cb49aeb into zombocoder:main Oct 27, 2026
6 checks passed
@sashml
sashml deleted the fix/map-containskey-resolution branch October 27, 2026 10:58
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.

3 participants