Skip to content

Add resolution diagnostic for multi-output procedure in expression position#1116

Merged
tautschnig merged 4 commits into
mainfrom
tautschnig/resolution-diagnostic
May 19, 2026
Merged

Add resolution diagnostic for multi-output procedure in expression position#1116
tautschnig merged 4 commits into
mainfrom
tautschnig/resolution-diagnostic

Conversation

@tautschnig
Copy link
Copy Markdown
Contributor

When a StaticCall to a multi-output procedure appears in expression position (not as the RHS of an Assign), emit an error diagnostic: the extra outputs would be silently discarded, which is a semantic bug (e.g., error channels lost).

The diagnostic is suppressed when the call is the direct RHS of an assignment (where the target count check already validates arity).

Includes a test in ResolutionKindTests demonstrating the diagnostic.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…sition

When a StaticCall to a multi-output procedure appears in expression
position (not as the RHS of an Assign), emit an error diagnostic:
the extra outputs would be silently discarded, which is a semantic
bug (e.g., error channels lost).

The diagnostic is suppressed when the call is the direct RHS of an
assignment (where the target count check already validates arity).

Includes a test in ResolutionKindTests demonstrating the diagnostic.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment thread Strata/Languages/Laurel/Resolution.lean Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Strata/Languages/Laurel/Resolution.lean Outdated
Comment thread Strata/Languages/Laurel/Resolution.lean Outdated
Comment thread Strata/Languages/Laurel/Resolution.lean Outdated
Address review feedback:
- Replace coarse inAssignRhs flag with inValueContext that is set when
  recursing into arguments of StaticCall/PrimitiveOp. This correctly
  diagnoses nested multi-output calls (e.g., f(multi(1))) while not
  firing for statement-position calls or direct assignment RHS.
- Factor out duplicate staticProcedure/instanceProcedure branches into
  a single outputCount lookup.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Comment thread Strata/Languages/Laurel/Resolution.lean
These are all value contexts where a multi-output procedure call
would silently discard outputs.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@keyboardDrummer
Copy link
Copy Markdown
Contributor

How about instead of this PR we look at merging #1121 ? I know this PR is a strict improvement, but I think it might be confusing to temporarily have this code. We'll have to make sure to remove it later as well. Since it's so easy to add a more long term solution, shouldn't we do that?

Copy link
Copy Markdown
Contributor

@keyboardDrummer keyboardDrummer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to wait for #1121, but approving in case you prefer not to wait

@tautschnig tautschnig added this pull request to the merge queue May 19, 2026
Merged via the queue into main with commit 7c3a3f0 May 19, 2026
21 checks passed
@tautschnig tautschnig deleted the tautschnig/resolution-diagnostic branch May 19, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants