Fix list_ops.vera runtime failure — built-in name shadowing (#154)#189
Merged
Conversation
User-defined functions now take priority over built-in intrinsics in WASM codegen. The built-in length(array) handler unconditionally intercepted any call to a function named "length", even when the user defined their own length() for a custom ADT. This produced invalid WASM because the built-in assumes array (ptr, len) pair format. The fix guards all 9 built-in handlers with a check against _known_fns so they only activate when no user-defined function exists. This also prevents the same class of bug for string_length, string_concat, string_slice, char_code, parse_nat, parse_float64, to_string, and strip. - examples/list_ops.vera now compiles and runs correctly (sum = 60) - 3 new tests in TestBuiltinShadowing (1,347 total) - Upgraded test_list_ops_example_file to verify runtime execution - Version 0.0.58 Closes #154 Co-Authored-By: Claude <noreply@anthropic.invalid>
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.
Summary
length) invera/wasm/calls.pyunconditionally intercepted calls by function name, even when the user defined their own function with that name. User-defined functions now take priority over built-in intrinsics.(i32, i32)pair on the WASM stack, but a user-definedlength(@List<Int> -> @Nat)passes a singlei32ADT pointer, producing invalid WASM.if call.name not in self._known_fns:, so user definitions always shadow built-ins.Test plan
vera run examples/list_ops.verareturns 60 (was crashing with type mismatch)TestBuiltinShadowing(user-defined length over ADT, single element, built-in still works)test_list_ops_example_fileupgraded from compile-only to runtime assertionCloses #154
Generated with Claude Code