fix: provide builtin ABS monomorphs for unsigned types - #1850
Open
ghaith wants to merge 1 commit into
Open
Conversation
Calling ABS with an unsigned argument bound to ABS__USINT/UINT/UDINT/ULINT, which the standard library does not provide; the shared object carried an undefined symbol and the call crashed at runtime. These monomorphs are now builtins that return the argument unchanged and report the new warning E150 because the call has no effect. Builtin validation is also dispatched under the resolved call name so the warning and argument-count checks fire for generic calls, and stub generation skips builtin implementations. Signed and float arguments still call the library implementations. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Build Artifacts🪟 Windows
From workflow run 🐧 Linux
From workflow run |
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
Calling
ABSwith an unsigned argument (USINT/UINT/UDINT/ULINT) resolved to a monomorph the standard library does not provide. The resolver synthesized an external declaration, the shared object carried an undefined symbol, and the call crashed at runtime.ABS__USINT/ABS__UINT/ABS__UDINT/ABS__ULINTare now builtins:ABS(UINT#1)toABS__UINTthrough its normalfind_poulookup — no resolver changes needed|x| = xfor unsigned values)ABScall is almost always a mistake, e.g. an argument expression that already underflowedSigned and float arguments are untouched and still call the library implementations.
Notes for review
generate_implementation_stubsskips builtin implementations so no deaddeclare @ABS__UINTlands in the IR.builtin_functions_named_arguments_invalid_parameter_names): its E037 message embeds a source slice from a type declared in the concatenated<builtin>unit, sliced against the wrong file — garbage before, differently-shifted garbage now that the builtin unit contains four more declarations. Might be worth a separate issue.Master counterpart (full builtin ABS with intrinsics): #1849
Test plan
cargo test --workspace./scripts/build.sh --lit(default +-Onone)abs_unsigned.st,abs_unsigned_warning.st)🤖 Generated with Claude Code