feat(aot): report multi-arity entries and group the frame's imports - #692
feat(aot): report multi-arity entries and group the frame's imports#692mparrett wants to merge 3 commits into
Conversation
1e234f6 to
bd93446
Compare
|
Reporting multi-arity instead of silently dropping to the VM fallback is the right fix for One shape regresses, though. Nit: |
bd93446 to
53928a8
Compare
53928a8 to
667cc51
Compare
|
(agent) Good catch on the list-form single arity — that was a real regression from the multi-arity reporting change. Unwrapped when the body is exactly one arity list in 9cd2686; covered Leaving the |
9cd2686 to
5cfd4a0
Compare
Two non-blocking notes from the #628 review. A multi-arity `(defn -main ([] …) ([x] …))` had no single binding vector to classify, so parse-entry-form returned nil — which reads as "no entry in this namespace" and quietly emitted the VM fallback frame. It now parses as an entry with an :unsupported shape, so the existing entry-arity-error path reports it and lg-compile exits non-zero, same as [first & rest]. The frame's import block was one undifferentiated group. gogen renders through a FileSet whose positions are densed so output stays a pure function of the AST (renderFset), and that pass also drops any blank line the printer would emit — so the goimports group break is restored on the rendered text instead, local to this frame rather than by loosening the renderer's determinism invariant. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The mainNotContain field added by the previous commit is longer than the surrounding names, so gofmt wants the whole block realigned. Pre-existing on the pushed branch, not introduced by the rebase.
(defn -main ([& args] …)) is valid Clojure, but parse-entry-form treated the lone arity list as multi-arity and hard-failed --entry-frame. Unwrap when the body is exactly one arity list; keep true multi-arity rejected. Co-authored-by: Cursor <cursoragent@cursor.com>
5cfd4a0 to
470284a
Compare
|
@nnunley I forgot to tag you after the last changes were pushed. Could you please take another look and see if the concerns were addressed? |
The two non-blocking notes from the #628 review, kept off that PR so its approval stays on the diff you read. Stacked on
wt/425-entry— merge #628 first and this retargets tomain.Multi-arity entries are reported instead of vanishing. A multi-arity
(defn -main ([] …) ([x] …))has no single binding vector to classify, soparse-entry-formreturnednil. That is the same answer as "there is no entry in this namespace," so the frame quietly fell back to the VM path and said nothing. It now parses as an entry with an:unsupportedshape, which routes into the existingentry-arity-errorpath:lg-compileprints a diagnostic naming the entry and exits non-zero, the same treatment[first & rest]already gets:Erroring rather than documenting-and-skipping seemed right for consistency: every other unsupported shape already stops the build, and a silent fallback is how this stayed invisible in the first place. The README's arity section now states the single-arity requirement alongside the supported shapes.
The frame's imports are goimports-grouped. One blank line between the stdlib specs and everything else:
The grouping is applied to the rendered text rather than the AST, because the AST cannot carry it.
gogen/renderbuilds a FileSet whose positions are densed gap-free so the rendered text is a pure function of the AST regardless of build concurrency (renderFset). A blank line is a position gap, so the determinism pass removes any group break carried on the tree. Rather than loosen that invariant for a cosmetic win, or pull inx/tools/importsfor one import block, the grouping is restored on the rendered text next to the existing header prepend — local to this frame, nothing else in the lowering pipeline sees it.Verified: the example rebuilds and runs unchanged (
fib.native→ 55,fib.native x→ 5702887), the generatedmain.goisgofmt-clean, andmake testpasses. Four new assertions cover both notes — two on the multi-arity diagnostic (public and private), two on the group break.