Skip to content

Variable in pattern match RHS marked as use of declaration in LHS #2264

Open
@toinehartman

Description

@toinehartman

Describe the bug

It seems that variables in the RHS of a pattern match can be resolved as a use of the declaration on the LHS of the match. This is suprising, since the LHS should only be declared after resolving the RHS.

To Reproduce

void f(int i) { // warning: "unused formal `i`"
    if (int i := i) { // RHS `i` resolves to LHS `i` instead of to formal declaration
        ;
    }
}

In this example, the i in the RHS of the pattern match resolves to the i in the LHS. Additionally, the formal parameter declaration int i is marked as unused, since the declaration int i in the LHS of the pattern match shadows it.

Expected behavior

  • First int i: formal declaration
  • Second int i: pattern var declaration
  • Third i: use of formal int i

Screenshots
Image

Desktop (please complete the following information):

  • Context: at least in VS Code
  • Rascal Version: 0.41.0-RC42

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions