Repository navigation
feat: PUC Rio correctness fixes - #57
Merged
Merged
Conversation
Replace mul_add-based modulo with v1 - floor(v1/v2)*v2 to match PUC-Rio's arithmetic and avoid fused-multiply-add precision differences.
…ssages
Lua 5.1 (llex.c) treats unrecognized escape sequences as the literal
character ('\z' is 'z', '\?' is '?'); only Lua 5.2+ rejects them.
Also quote partial string content in syntax errors to match PUC-Rio's
txtToken behavior, improving debugging for unterminated strings.
PUC-Rio 5.1 llex.c with LUA_COMPAT_LSTR == 1 rejects nesting of [[...]] inside a level-0 long string or comment. Different delimiter levels (e.g. [=[ ... ]=]) are still allowed.
Lua 5.1 only allows '...' in the main chunk and functions explicitly declared with varargs. PUC-Rio checks fs->f->is_vararg; rilua was missing this validation.
Replace heuristic chunk ID generation with a byte-exact port of luaO_chunkid from lobject.c. Fixes truncation logic for filenames, string sources (truncates at first newline), and literal names.
CI[0] is never a valid stack level (PUC-Rio: if level == 0 && ci > L->base_ci). The old special-case for CI[0] was an artifact of lua.c's lua_cpcall wrapper; with the real C API that frame exists naturally.
… compat)
Library functions that raise Runtime errors now get their message
prefixed with the calling Lua function's location, matching PUC-Rio's
luaL_where(L, 1) behavior. Excludes VM-style errors ('attempt to ...',
'loop in ...') and already-prefixed messages.
PUC-Rio's str_find_aux clamps init to the subject length: if (init > l1) init = l1. Without this, negative indices beyond string length cause underflow when converting to 0-based.
PUC-Rio's GCTM() disables hooks before calling __gc metamethods to prevent re-entrancy issues. Without this, a __gc finalizer that triggers GC could cause infinite recursion or corrupt state.
This reverts commit 64891f8.
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.
Pull Request
Summary
This PR fixes a handful or issues where
riluashowed a different behavior compared to the originallua5.1 implementation.Changes
Type of Change
functionality to not work as expected)
Tested On
Quality Checklist
By submitting this PR, I confirm that: