Repository navigation
fix: accept both isEmpty and empty on List, Map and Set - #19
Merged
zombocoder merged 1 commit intoOct 27, 2026
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The collection emptiness check has a different spelling per type:
Listdispatches onlyisEmpty(),while
MapandSetdispatch onlyempty(). Solist.empty(),map.isEmpty()andset.isEmpty()each fail at runtime with
Unknown method '...' on <T> type, and callers have to remember whichspelling goes with which collection.
Fix
In the three method-dispatch sites in
MethodCallNode, accept bothisEmptyandemptyonList,MapandSet. The argument-count error now names the method that was actually called. Purelyadditive: existing code keeps working.
Tests
examples/test_collection_isempty_alias.obq: both spellings on empty and non-emptyList,MapandSet.Verification
o2l_tests509/509 passing; theexample passes.