errors: thread operand hints into arith & bitwise type errors#270
Merged
Conversation
Append PUC-Lua-style `(global 'X')` / `(local 'X')` / `(upvalue 'X')` / `(field 'X')` suffixes to arithmetic and bitwise type errors and to "number has no integer representation" failures. Closes the remaining half of #252 — wording already matched; only the trailing hint was missing. Codegen now resolves each binop / unop operand AST node to a hint tuple via the existing `name_hint/2` and bakes it into the instruction tuple (same pattern as `:get_field` / `:call`). The executor and the v2 dispatcher both thread the hint of the failing operand into the raise helpers; `format_target_hint/1` renders the suffix. Bytecode encoding preserves hints, so on-disk prototypes keep the suffix on errors. Encoded tuple shape changes are isolated to the 14 affected opcodes. Updates skip reasons for math.lua / sort.lua / errors.lua / strings.lua to drop the now-resolved "checkerror format mismatch" blocker. Remaining blockers there are behavioural (finite math.huge, timeouts, parse-error templates) and tracked separately. Plan: A40 Closes #252
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
Closes the remaining half of #252 — the wording already matched PUC-Lua;
only the trailing
(global 'X')/(local 'X')/(upvalue 'X')/(field 'X')hint suffix was missing.operands' lexical origin via the existing
name_hint/2and bakes theresult into the instruction tuple. Same pattern as
:get_field,:set_field,:call,:self.raise_arith_type_error/4,to_integer!/4, andfloat_to_integer!/3now take a hint and append it viaformat_target_hint/1. Thesafe_*helpers pick the failingoperand's hint correctly.
dispatcher_binop/dispatcher_unopthread them through to thesame raise paths — so compiled prototypes also surface the hint.
math.lua/sort.lua/errors.lua/strings.luaskip reasons updated to drop the now-resolved"checkerror format mismatch" blocker. Remaining blockers are
behavioural (finite
math.huge, timeouts, parse-error templates)and tracked separately.
Examples
return foo + 1(foo nil global)arithmetic on a nil valuearithmetic on a nil value (global 'foo')local x; return -xarithmetic on a nil valuearithmetic on a nil value (local 'x')local t={}; return t.x + 1arithmetic on a nil valuearithmetic on a nil value (field 'x' on local 't')return math.huge << 1number has no integer representationnumber has no integer representation (field 'huge' on global 'math')local s='x'; return s << 1bitwise operation on a string valuebitwise operation on a string value (local 's')Test plan
mix test— 1963 passed (was 1955), 25 skipped — 8 new pin testsfor the hint suffix across all four origin tags × arithmetic /
bitwise / integer-representation.
mix format --check-formattedmix compile --warnings-as-errorsmix dialyzer— no new errors (pre-existing one intasks/suite_runner.exunchanged).test/lua/vm/error_format_test.exs—arithmetic type error carries operand hint+bitwise type error carries operand hintdescribe blocks pin every rendering.
Closes #252.
Plan: A40