chore: resolve in-source TODOs#194
Merged
Merged
Conversation
Implements load() with a reader-function argument (Lua 5.3 spec), wires
compile-error formatting through the parser's source-context output, and
clarifies the compiler.ex error-handling note now that the compiler still
raises rather than returning {:error, _}.
- stdlib.load: accept a reader function; concat pieces until nil/empty
string; reject non-string non-function args; pass-through to the
existing parse+compile path.
- CompilerException.message/1: drop the stale 'Re-add stacktrace'
comment. Compile-time errors don't have a runtime stack; rich source
context (line, column, pointer) is already produced upstream by
Lua.Parser.Error.format/2.
- Compiler.compile!/2: replace the dead-branch TODO with a forward note
explaining the {:error, _} branch is reserved for when codegen is
converted to thread results instead of raising.
Plan: A11
Closes #172
davydog187
added a commit
that referenced
this pull request
May 6, 2026
- Status: bump date to 2026-05-06 and unit count to 1369/36 skipped - Polish: strike A11 with shipped-in PR #194 reference
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.
Resolve in-source TODOs (compiler error handling, stacktrace formatting, load reader chunks)
Plan:
.agents/plans/A11-source-todos.mdCloses #172
Goal
Clean up three in-source TODOs that have been lingering since the rewrite,
now that the prerequisite features are in place.
Success criteria
mix testpasses (1357 → 1369, no regressions)they're being intentionally deferred.
grep -n "TODO" lib/shows three fewer hits in the targeted files(in fact lib/ now has 0 TODOs).
Changes
lib/lua/compiler.ex— TODO #1The compiler still raises rather than returning
{:error, _}, so theTODO's premise ("now that the compiler can return errors") isn't yet
true. The dead
casebranch incompile!/2has been replaced with aclearer forward note explaining what would need to change first
(threading results through codegen instead of raising).
lib/lua/compiler_exception.ex— TODO #2Compile-time errors don't have a runtime stack — they happen before any
code runs. The rich source context (line, column, pointer to the
offending token) is already produced upstream by
Lua.Parser.Error.format/2, andCompilerException.message/1alreadyforwards it under the "Failed to compile Lua!" header. The stale
"Re-add stacktrace formatting" comment has been replaced with a note
explaining this. New tests in
test/lua/compiler_exception_test.exsassert the formatted output includes line, column, and the offending
source line.
lib/lua/vm/stdlib.ex— TODO #3Implements reader-function
load(reader)per Lua 5.3 spec:{:lua_closure, ...}and{:native_func, ...}callees.nil,"", or no return value.(nil, error_message)if the reader returns a non-stringnon-nil value.
Seven new tests in
test/language/load_test.exscover concatenation,all three end-of-chunk signals, non-string returns, syntax errors in
reader-supplied source, and rejection of non-string non-function args.
Discoveries
test/lua/vm/stdlib_load_test.exs, but the existing convention istest/language/load_test.exs. I added the reader-function tests thereto keep with the codebase convention; new compiler-exception tests
live in
test/lua/compiler_exception_test.exs(no prior fileexisted).
plan anticipated this case: "If no, document why and leave the TODO
in place with a clearer explanation." The TODO comment is gone but
replaced with a forward note about the codegen refactor required to
make the error path real.
formatted errors with source context already; the missing piece in
the original TODO was a runtime stacktrace, which doesn't apply at
compile time. The remaining work was clarifying that and adding
tests asserting the format includes source location.
lib/now has zero TODOs. Outpaced the success criterion of"three fewer hits in the targeted files."
Verification
All green:
Out of scope (intentional)
lib/after this PR).prerequisite for the original TODO Pull in code #1 and stays deferred until
codegen is rewritten to thread results.