Repository navigation
Conversation
…oop and branch bodies A while, loop, for, if or else body reads its statements through parseActionMember, whose keyword dispatch reported an import, an alias or a visibility prefix as an unknown action keyword. These open a NonBehaviorBodyItem, so parseActionMember now hands them to the body member parser, as it does for the members only some body kind owns. Refs #2668 Co-Authored-By: jason.han <hanhuijun@gmail.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
A loop or branch body with no flow of its own lowered each member as a step, so an import or an alias became an unsupported statement and the run stopped with 'statement not executable'. Such a body now skips the members that state no step, as a body with a flow already does. Co-Authored-By: jason.han <hanhuijun@gmail.com>
There was a problem hiding this comment.
Devin Review found 1 finding. Devin automatically fixed it.
Fixed by Devin (1)
- Imports and aliases abort action runs — Confirmed:
while w < 2 { private import Q::*; assign w := w + 1; }aborted withstatement not executable.lowerBlocknow skips members that state no step, as a body with a flow already does; a new execution conformance fixture fails without the fix. The commit is local and is pushed once the CI coordinator releases a slot.
QA: PASS on
|
| Surface | Base | Head |
|---|---|---|
sysml -validate on import / alias in while, loop, for, if, else bodies |
unknown action keyword: private/import/alias |
no errors |
-convert sysml and -convert api-json |
n/a (syntax errors) | all imports and aliases written back; the converted file validates; alias Membership present in the JSON |
Alias name resolution (alias X for Q::T; part v : X; in each body kind) |
syntax error | resolves; hover on the usage gives part def T, go-to-definition reaches Q::T, rename of the alias edits both sites |
VS Code + sysml-lsp |
16 problems | 0 problems; hover, F12, typing a new alias in a for body stays clean; malformed alias for; still reports expected a name |
gRPC ParseSources |
16 syntax diagnostics | 0 diagnostics |
Execution (%action test::run on the new conformance fixture) |
n/a | completes with w=2, l=3, f=6, taken=1, skipped=3 |
PR's TestLoopAndBranchBodiesAdmitImportAndAlias |
13 of 30 subtests fail | 30 of 30 pass |
Nothing else in parsing moved.
- 297 generated models (every body kind × valid and malformed import/alias/visibility members, nested bodies, ordinary action bodies), each through
-validate,-strict -validate,-convert sysml,-convert api-json: the only base/head differences are the intended ones (the members are admitted; malformed ones get the body-member parser's diagnostics instead ofunknown action keyword). - All 4,496
.sysml/.kermlfiles in the tree through-validateand-convert sysmlon base and head: byte-identical output (one line differs only by the checkout path). TestStdlibConformance,./internal/syntax/...,./tests/parser(golden and negative),./tests/resolve,./internal/ir/lower,TestExecutionConformance|TestExecutionTrace|TestRuntimeRobustness,TestGRPCConformance: pass.go build ./...,go vetandgofmt -lon the touched packages: clean.
Past fixes in the touched areas (77 rows: parser/lexer/formatter, action bodies, import, alias; 15 of them from Tim Weilkiens's reports):
- 67 rows pass by the tests their fix added (334 test functions across 39 packages pass; 1,
TestTMTLayout, skips itself). - 9 rows have no test function of their own (metadata construct not parsed — VerificationMethodKind annotations fail with 'expected a body member' #608, fix(runtime): synchronize action tokens by incoming succession #116, fix(parser): reject prefix conflicts, bad escapes and misplaced body members the grammar forbids #210, fix(parser): resolve the payload type of a bare accept trigger #683, fix(parser): end node spans at their last token, not the next token's start #687, fix(parser): read end multiplicities on a keyword-less action succession #983, fix(grpc): validate a dry run's last import, decide nothing-compared configurations, Julia applied on an empty import #1245, fix(vscode): report a draw.io import from one tested helper #1705, fix(resolve): give an imported membership the visibility of its import #2160) and are held by fixtures: the parser golden/negative, runtime conformance and gRPC conformance suites that hold most of them pass locally, the rest rely on hosted CI. fix(parser): read end multiplicities on a keyword-less action succession #983 (end multiplicities on
first … then …) was also rerun by hand with imports and aliases in the samewhileandloopbodies, clean. fix(vscode): report a draw.io import from one tested helper #1705 is a VS Code TypeScript test and was not run. - 1 row (fix(runtime): run the successions an inline state action body states #169): its
./internal/ir/lowertests pass; theTestRuntimeRobustnessname recorded fortools/census/doccountsmatched no test there. - Tim Weilkiens rows: fix(parser): read end multiplicities on a keyword-less action succession #983, fix(parser): accept a direction on every usage kind a behavior body admits #1094, fix(lexer): let string literals and unrestricted names span lines #1096, fix(resolve): bind the short name a redefining feature takes from the redefined one #1112, fix(check): judge inherited and KerML typings by the kind's redundant-type rule #1163, fix(runtime): type an object by every type its feature inherits through subsetting #1276, fix(check): judge cast conformance at the head of a feature chain #1510, fix(project): read an unrecorded (NONE) checksum and both checksum shapes in .meta.json #1522, fix(project): read a sub-package through its own installation alone #1523, fix(project): follow a loaded file's qualified names to the files declaring their roots #1524, fix(repl): search beside a loaded file for the roots the analysis left unresolved #1528, fix(check): report a succession end its action does not feature #1530, fix(project): link a usage by elimination only when its resource spells a location #1561, fix(project): bundle the files a project's .meta.json records #1566, fix(project): read a usage's repository from the ECMA-427 vcs_url qualifier #1737 all hold. fix(parser): accept a direction on every usage kind a behavior body admits #1094 (directed usages), fix(lexer): let string literals and unrestricted names span lines #1096 (multi-line literals), fix(resolve): bind the short name a redefining feature takes from the redefined one #1112 (derived short names) and fix(check): report a succession end its action does not feature #1530 (succession ends; an end naming nothing is still reported inside a
loopbody) were additionally exercised by hand with an import and alias in the loop/branch body.
Hosted CI on 0ef51b212a: 20 passed, 0 failed, 0 pending, 13 skipped (the client, editor-plugin, PDF and derived-property jobs, skipped by the changed-areas filter).
Gaps
-
An import in a loop or branch body brings no names into scope.
private import Q::*; part v : T;inside awhile,loop,for,iforelsebody reportsunresolved reference: Ton head, while the same two members in an ordinary action body (action s { … }) resolve. The PR description declares this out of scope, and forloop/for/if/elsebase behaves the same, so it is not a regression; but the imports this PR admits are not usable yet. -
-querydoes not see members of a loop or branch body.oslc.where=rdf:type="Membership"returns the alias of an ordinary action body butno elements matchedfor the same alias in awhile/loop/for/if/elsebody. Same on base for other members (apartin awhilebody is not returned forPartUsageeither), so it predates this PR.
For the record, the first head (316bfcb80b) parsed these bodies but failed to execute them (statement not executable: action node : \then` statement in a body is not executable); 0ef51b2` fixes that.
316bfcb80b: execution fails |
0ef51b212a: expected values |
|---|---|
Not run
- The full
go test ./...and-racetiers locally (hosted CI covers them); only the suites listed above. - The VS Code extension's own test suite, and the Emacs, JupyterLab, SysON and Magic plugins.
- LSP folding ranges (
sysml-lspanswersnot implementedon base and head). - No alias-specific completion was observed inside the bodies on either side; completion offers
Qandnon both.
QA: pass — 0ef51b2 against develop 83249b3 (race re-runs of four packages and the tools module still running, result to follow)Exact head Gates on the head
Failing-first
Behavior, base vs headParsing (
Execution (REPL
So on the head the import and alias are no-ops at run time and the other statements run normally; the plain body is unchanged. Resolution (unchanged, not this PR's)
Grammar basis
Observations (not failures of this PR)
Not coveredLSP, gRPC clients and Jupyter surfaces were exercised only through the suite, not by hand. Race results for |
What and why
A
while,loop,for,iforelsebody rejected members that a plain action body accepts, and an action stopped when it ran a body holding animportor analias. Closes #2668.Before,
sysml -validateon this model:After, no syntax error is reported.
Root cause: these bodies read their statements through
parseActionMember, whose keyword dispatch has no arm for a visibility prefix,importoralias, so each fell to theunknown action keyworddefault. Thewhilebody sent every member there; theloop,forandifbodies only sent whatatDefUsageStartdoes not recognize, which is why they failed on an unprefixedaliasonly.parseActionMembernow hands a visibility prefix, animportand analiastoparseBodyMember, next to where it already does so for the members only some body kind owns. One change covers all five bodies and leaves every existing golden AST unchanged.private import Q::*;/public import Q::*;private alias TT for Q::T;alias TT for Q::T;import Q::*;import-visibilityunknown action keyword, nowimport-visibilityEvery cell is accepted now, the last row with its
import-visibilitydiagnostic only.Running such a body
Once these members parse, a body with no flow of its own lowered each of them as a step, so running the action stopped at the import or alias:
lowerBlock(internal/ir/lower/action_graph.go) now skips the members that state no step (statesNoStep), as a body with a flow already does.while w < 2 { private import Q::*; alias W for Q::T; assign w := w + 1; }runs tow = 2.Out of scope
Tis still reported unresolved in thewhilebody: an import in a loop or branch body does not yet bring names into scope. That is semantic scoping work, not parsing, and is left to fix(semantics): reflect action node parameters #2617 and its follow-ups.private assign n := n + 1;(a visibility-prefixed action node) is rejected withexpected a body memberin every action body, a plain one included. That was so before this change and is not touched here.Specification basis
SysML.xtext: the body of a
WhileLoopNode,ForLoopNodeandIfNodeis anActionBodyParameter, whose body isActionBodyItem*.ActionBodyItemincludesNonBehaviorBodyItem, which includesImportandAliasMember. No compliance row moves.How it was verified
go test ./internal/syntax/parser -run TestLoopAndBranchBodiesAdmitImportAndAliasfailed 13 of its 30 subtests before the fix (the cells marked above) and passes all 30 after it.tests/parser/testdata/parse/action_loop_branch_import_alias.sysml: 5 imports and 6 aliases across the five bodies, noErrorNode.go test -run TestGolden -update ./tests/parserchanged no existing golden.develop):go build ./...andgo vet ./...in the root andtoolsmodules,gofmt -l .(empty),make lint,make docs-counts,python3 scripts/changelog.py check,python3 scripts/check-doc-ids.py,go test -race ./internal/syntax/parser ./tests/parser, andgo test ./internal/syntax/... ./tests/parser ./tests/hygiene ./internal/workspace/... ./internal/frontend/lsp/... ./client/opensysml/...(includesTestStdlibConformanceandTestNegative).go test -timeout 55m ./...passed (141 packages) on the commit before thedevelopmerge; the merge brought in only client, LSP and workspace-model changes, whose packages were re-run above.internal/exec/runtime/testdata/conformance/action_loop_branch_import_alias.sysml(an import and an alias in awhile,loop,for,ifandelsebody) failed with the error above before the lowering change and passes with it.go test -count=1 ./internal/ir/... ./internal/exec/runtimepasses on this head, withgo build ./...,go vetover both trees,gofmt -l,make lint,make docs-counts,python3 scripts/changelog.py checkandgo test ./tests/hygiene. The full suite was not re-run after this commit.-race(make test), andgo test -C tools ./...beyond themake docs-countspackages.Try it:
Checklist
make testandmake lintpass locally (make lintpasses;go test ./...passed without-race, see above)changes/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (compliance rows need nothing: the census is counted at docs build)F4,K5) in the body, docs, or changelogImplemented in session Fix import and alias parsing in action bodies
Review with Devin · Open in Devin Desktop