Skip to content

fix: accept both isEmpty and empty on List, Map and Set - #19

Merged
zombocoder merged 1 commit into
zombocoder:mainfrom
Craftegy-NextGen:fix/collection-isempty-aliases
Oct 27, 2026
Merged

zombocoder merged 1 commit into
zombocoder:mainfrom
Craftegy-NextGen:fix/collection-isempty-aliases

Conversation

@sashml

@sashml sashml commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The collection emptiness check has a different spelling per type: List dispatches only isEmpty(),
while Map and Set dispatch only empty(). So list.empty(), map.isEmpty() and set.isEmpty()
each fail at runtime with Unknown method '...' on <T> type, and callers have to remember which
spelling goes with which collection.

Fix

In the three method-dispatch sites in MethodCallNode, accept both isEmpty and empty on List,
Map and Set. The argument-count error now names the method that was actually called. Purely
additive: existing code keeps working.

Tests

  • Runnable example examples/test_collection_isempty_alias.obq: both spellings on empty and non-empty
    List, Map and Set.

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 collection emptiness API was inconsistent at the O2L language level:
List dispatched only isEmpty(), while Map and Set dispatched only empty().
As a result list.empty(), map.isEmpty() and set.isEmpty() each raised
"Unknown method '...' on <T> type" at runtime, forcing callers to remember
a different spelling per collection type.

Make isEmpty and empty aliases in all three method-dispatch sites so either
spelling resolves on every built-in collection. The emptiness-check
argument-count error now reports the actual method name used.

Adds a runnable regression example
(examples/test_collection_isempty_alias.obq, 15 assertions) exercising both
spellings on empty and non-empty List, Map and Set.

Signed-off-by: svaiml <88979468+svaiml@users.noreply.github.com>
@zombocoder
zombocoder merged commit de8ae54 into zombocoder:main Oct 27, 2026
6 checks passed
@sashml
sashml deleted the fix/collection-isempty-aliases 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