feat(stdlib): utf8 library + align integer-arith error wording#258
Open
davydog187 wants to merge 1 commit into
Open
feat(stdlib): utf8 library + align integer-arith error wording#258davydog187 wants to merge 1 commit into
davydog187 wants to merge 1 commit into
Conversation
Implements the Lua 5.3 §6.5 `utf8` standard library — `char`, `codepoint`, `codes`, `len`, `offset`, `charpattern` — covering the 0x0..0x10FFFF range with overlong/invalid-sequence detection. The official suite's `utf8.lua` now passes outright and is promoted out of the skip list. Also normalises integer-arithmetic error phrasing to match PUC-Lua: "attempt to perform 'n//0'" (was "attempt to divide by zero") and "attempt to perform 'n%0'" (was "attempt to perform modulo by zero"). Adds an `ArgumentError.wrong_number_of_arguments/1` helper as the shared constructor for the variadic-stdlib runtime-error template. Each touched template is pinned with a unit test in `test/lua/vm/error_format_test.exs`. Closes #253. Progresses #252 (the listed `n//0`, `n%0`, and "wrong number of arguments" templates; field-hint threading on arithmetic sites deferred to a follow-up — requires plumbing target hints through all `raise_arith_type_error` callsites).
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.
Bundles two T1 suite-progress issues: implements the
utf8stdlib (#253) and normalises a handful of stdlib/executor error templates to match PUC-Lua wording (#252).Summary
utf8standard library (lib/lua/vm/stdlib/utf8.ex): full Lua 5.3 §6.5 surface —char,codepoint,codes,len,offset,charpattern. Validates the 0x0..0x10FFFF range, rejects overlong sequences, continuation-byte starts, and codepoints above U+10FFFF. The official suite'sutf8.luanow passes outright and is removed fromtest/lua53_skips.exs.1 // 0→"attempt to perform 'n//0'"(was"attempt to divide by zero")1 % 0→"attempt to perform 'n%0'"(was"attempt to perform modulo by zero")ArgumentError.wrong_number_of_arguments/1constructor: shared helper for the PUC-Lua "wrong number of arguments to 'X'" runtime-error template.table.insertnow routes through it; other variadic stdlib sites can adopt as they're audited.test/lua/vm/error_format_test.exs.Out of scope (follow-ups for #252)
Threading
(field 'X')/(global 'X')/(local 'X')target hints into arithmetic-type errors (e.g. somath.huge << 1surfacesfield 'huge') requires plumbing a hint parameter through everyraise_arith_type_errorcaller — eight callsites, plus the VM dispatcher that knows the operand's lexical origin. Left for a follow-up because it's a larger refactor than the wording fixes in this PR.The other
:all-deferred suite files (math.lua,sort.lua,errors.lua,strings.lua) still fail at early, non-wording-related assertions and stay:all-skipped; further narrowing depends on the field-hint work above plus other behavioural fixes.Test plan
mix test— 1953 passed (was 1914 on baseline), 25 skipped (was 26 —utf8.luapromoted out)mix format --check-formattedmix dialyzer— no new errors (one pre-existing onmainintasks/suite_runner.ex)test/lua/vm/stdlib/utf8_test.exs— 29 tests covering happy path + every error templatetest/lua/vm/error_format_test.exs— 9 tests pinning every PUC-aligned templateCloses #253. Progresses #252.