cli: engine flags share non-ident positional -> main heuristic with default#341
Merged
Merged
Conversation
PR #329 propagated the no-positional auto-pick-main heuristic from the default engine (PR #307) to --run-tree / --run-vm / --run-cranelift, but skipped PR #328's other half: when the first positional is non- ident-shaped (paper.txt, /tmp/x.json, 42), the default engine routes to main with the positional as arg #1, while the explicit-engine flags still treated the positional as a function name and surfaced ILO-R002: undefined function: paper.txt. Extend resolve_engine_func_name to share the same check: if looks_like_subcommand_name(first) is false and main is defined, route to main with the whole rest slice as call args. Ident-shaped typos still fall through to the engine and surface the existing undefined-function diagnostic, so PR #329's typo-detection contract is preserved verbatim. Reported by pdf-analyst, devops-sre, and qa-tester independently in rerun7.
Mirrors the structure of the PR #329 engine-flag-auto-pick-main block: one helper per scenario, fanned out across --run-tree / --run-vm / --run-cranelift (+ default-engine pin where useful). Scenarios covered: - non-ident positional (paper.txt) routes to main - path-shaped positional (/tmp/x.json) routes to main (devops-sre repro) - numeric positional (10, 32) routes to main as multi-arg call - explicit main keyword + non-ident positional still works - explicit helper ident overrides the main heuristic - ident-shaped unknown with no main still errors clearly 24 new tests; the default-engine pin guards against future drift between default and explicit-engine code paths.
Acts as both an agent-learning artefact (shows the correct shape for 'pass a path argument to main on a multi-fn file' across every engine flag) and a harness-level regression run through tests/examples_engines.rs on every backend.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
PR #329 propagated half of the default-engine entry-point heuristic to the explicit-engine flags (
--run-tree/--run-vm/--run-cranelift): when there's no positional after the source path, auto-pickmain. It didn't propagate PR #328's other half: when the first positional doesn't look like a function name (paper.txt,/tmp/x.json,42, anything with a.or/or leading digit) andmainis defined, route tomainwith the positional as arg #1.Three rerun7 personas (pdf-analyst, devops-sre, qa-tester) hit the same asymmetry independently:
This PR extends
resolve_engine_func_name(src/main.rs) to share the samelooks_like_subcommand_namecheck the default-engine path uses. Surgical fix, mirrors a check that's already documented and well-tested elsewhere.Repro before/after
/tmp/repro.ilo:Before:
After:
What's in the diff
cli: engine flags route non-ident first positional to main(1cd81db) — the four-line guard inresolve_engine_func_name. Identical predicate to the default-engine branch at src/main.rs ~2838-2857, so future drift between the two paths is easier to spot.tests: cross-engine regression for non-ident positional dispatch(89bed33) — 24 new tests inregression_cli_default.rsmirroring the PR cli: auto-pick main on --run-tree / --run-vm / --run-cranelift #329 block: one helper per scenario, fanned out across--run-tree/--run-vm/--run-craneliftplus a default-engine pin. Covers non-ident positional, path-shaped positional, numeric positional, explicitmainkeyword + non-ident arg, explicit helper override (must NOT be shadowed by the heuristic), and ident-shaped-unknown-no-main (must still error).examples: pin non-ident positional routing across engines(8b04f63) —examples/engine-flag-non-ident-positional.iloruns through the engine harness on every backend, so a future regression here fails at cross-engine parity rather than waiting for another persona to file it.Test plan
paper.txt,/tmp/x.json, explicitmain, and explicithelperon every backendFollow-ups
ilo --run-tree 'f a:n b:n>n;/a b' 10 0with one fn, no main) is NOT covered here. The narrow brief was "share cli: hyphenated subcommands + non-ident positionals route to main (#320 follow-up) #328's non-ident -> main heuristic", and that case has nomainto route to. Worth a follow-up to consider a single-fn inline auto-run on the explicit-engine paths, but it's a wider design call than this PR.