Repository navigation
feat(desugar): a qualified constructor takes its arguments (E7, part 2) - #430
Conversation
`M.Ctor(x)` parses as a call of the member `M.Ctor`. The desugarer read
the member alone as a constructor with no arguments, so a constructor
with fields was an arity error ("expects 1 arguments, got 0").
The desugarer now reads the full call: when the head of a call is
`M.Ctor` and `M` is an imported module, the arguments of the call are
the arguments of the constructor. `M.Ctor()` is the constructor with no
arguments, as `Ctor()` is.
An unknown qualifier and a wrong number of arguments keep their errors.
The qualifier still resolves unqualified, as `M.f` does.
Gate: the probe `qa/app2` checks, compiles and runs (9), as wasm and in
the interpreter. Tests: 606 all-target.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0136P7ZmKrYLDC4WHi2yt11u
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 18 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
The type checker refused a generic `main` in each module. A `main` of an imported module is not an entry point: `run` starts the `main` of the root, and an imported `main` without type parameters was already a function like any other. A program that imported a module with a generic `main` was a type error. The driver now makes this check, on the root module only. The error is the same `TypeError::GenericMain`. Review finding on #429. Tests: 607 all-target. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0136P7ZmKrYLDC4WHi2yt11u
|
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0966fdc079
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if nullary | ||
| && matches!( | ||
| args[..], | ||
| [SurfaceExpr { | ||
| kind: SurfaceExprKind::Lit(Literal::Unit), |
There was a problem hiding this comment.
Preserve empty calls separately from unit arguments
This heuristic cannot distinguish M.Dot() from M.Dot(()), because parse_postfix_expr represents both as App(M.Dot, Lit(Unit)). Consequently, for data T = Dot, the explicitly supplied argument in M.Dot(()) is silently discarded instead of producing an arity error; conversely, for data T = Wrap(Unit), M.Wrap() is accepted as though one argument were supplied, unlike the equivalent unqualified Wrap(). The parser or surface AST needs to preserve whether the call's argument list was actually empty before constructor arity is checked.
Useful? React with 👍 / 👎.
`M.Ctor(x)` works as an expression since #430. The same form in a match pattern did not parse: `| shapes.Rect(w, h) => ...`. - Grammar: `constructor_pattern` takes an optional `pattern_qualifier` and a `.` before the constructor name. - The surface parser keeps the qualifier in the name (`M.Ctor`). The desugarer checks that `M` is an import of the module, and finds `Ctor` in the scope of the module. So the visibility rule of #431 holds: a private type is "unknown constructor". - The core parser fallback has no list of imports: it does not check the module there. Part 1 of spec/ephapax-v2-grammar.ebnf is written again from the grammar. Tests: 2 programs on both engines (with and without a guard) and 2 refused programs. 618 all-target. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0136P7ZmKrYLDC4WHi2yt11u



Summary
M.Ctor(x)now builds a value of a data type of the imported moduleM. This is theM.Ctor(x)item of rung E7 in the v2 plan. A second commit fixes a late review finding on #429.The defect
lib2.MkBox(9)parses as a call of the memberlib2.MkBox. The desugarer read the member alone as a constructor with no arguments. A constructor with fields was then an arity error:The change
src/ephapax-desugar/src/lib.rs: the desugarer reads the full call. When the head of a call isM.CtorandMis an imported module, the arguments of the call are the arguments of the constructor (qualified_ctor_call).M.Ctor()is the constructor with no arguments, asCtor()is.Review finding on #429 (second commit)
The type checker refused a generic
mainin each module. Only themainof the root module is an entry point, so a program that imported a module with a genericmainwas a type error. The driver now makes this check, on the root module only (check_program). The error is the sameTypeError::GenericMain.Not in this change
M.fdoes.| M.Ctor(v) => ...) are not in the gate.Verification
qa/app2checks, compiles and runs (9), as wasm and in the interpreter. The 4qa/app2rows oftests/probes/expectations.tsvnow have the target as baseline.a_qualified_constructor_takes_its_arguments(src/ephapax-cli/tests/run_wasm.rs): constructors with 0, 1 and 2 fields, 2 inputs each, on both engines; the 2 load errors.a_generic_main_of_an_imported_module_is_not_an_entry_point(src/ephapax-cli/tests/generics.rs).cargo test --workspace: 610 passed, 0 failed.cargo fmt --all --checkandcargo clippy --workspace --all-targets: clean.scripts/status-gate.sh: 607 all-target tests.scripts/probe-battery.sh: 51 SAME, 7 SKIP (the SKIP rows need the wasmtime CLI).🤖 Generated with Claude Code
https://claude.ai/code/session_0136P7ZmKrYLDC4WHi2yt11u