Repository navigation
Conversation
With -m there is no script argument, so the storage id fell through to the executable's basename: every -m program shared the "lg" store with the REPL, and a program launched as `lg app.lg` lost its data when launched as `lg -m app`. Derive the id from the namespace's file path instead, so `lg -m app.core` uses the same store as `lg src/app/core.lg`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
runNamespaceMain passed rt.InvokeProgramEntry's errors through, so users saw "InvokeProgramEntry: app/-main not found". Look up and check the entry in the namespace RequireNS returns and report "-m: app/-main not found". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #1096.
lgcan load a namespace's source file but has no CLI entry point for calling its-main. Programs currently need a launcher script or a manual-ecall, which also prints the return value and treats the first program argument as a script.Adds
lg [-source-paths …] -m ns [args…]and--main. The namespace is required through the existing loader, all remaining arguments are bound to*command-line-args*before initialization/loading and passed as strings tons/-main, and the return value is discarded. Loading and invocation failures exit nonzero.Design choices:
-m ns/fnselects another callable var.-mis terminal: even flag-shaped arguments and a literal--after the target belong to the program. Other options must precede it.-eruns before requiring/calling the target, with the arguments already available; its result still prints as usual. An initialization error prevents the entry call. Existing script-plus--eordering stays unchanged.-rretains the existing post-execution REPL behavior. Combining-mwith-c,-b, or-wis a usage error.The CLI reuses
rt.RequireNSandrt.InvokeProgramEntry. No compiler, IR, AOT, or generated runtime changes are needed; the default and bootstrap builds exercise the same entry path, and an*ir-compile*initialization probe also passes.Validation:
make build(including correctness and boot smoke): passed.make test: passed (uninitialized Clojure test-suite submodule and normal short-mode skips).go test ./test/e2e -run 'TestMainFlag|TestCommandLineArgs' -count=1 -v: passed; 20 new CLI cases plus existing script/bundle argument coverage.go test -tags bootstrap ./test/e2e -run TestMainFlag -count=1: passed.go test -short ./pkg/cli/...andgo vet ./pkg/cli/...: passed, including 11 parser cases covering custom host flags, positional scripts, terminators, and malformed flags.Local lint limitation: both
make lint-goand the pinned pre-commit linter stop in typechecking before analyzing the changes because their importer supports Go export-data version 4 while local Go 1.27.3 emits version 5 (internal/goarch). Only that pre-commit hook was skipped; the remaining commit hooks passed.