Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: typeof.exprreferences out-of-scope variables in rare cases #725

Open
Jezurko opened this issue Sep 11, 2024 · 0 comments
Open

[Bug]: typeof.exprreferences out-of-scope variables in rare cases #725

Jezurko opened this issue Sep 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Jezurko
Copy link
Collaborator

Jezurko commented Sep 11, 2024

VAST version

master

LLVM version

18.1.8

Operating system

Linux (Solus)

Description

({
  int x = 5;
  typeof(x) y = x;
  y;
})

generates

 hl.typeof.expr "(x)" {
            %3 = hl.expr : !hl.lvalue<!hl.int> {
              %4 = unsup.stmt "DeclRefExpr" : !hl.int
              hl.value.yield %4 : !hl.int
            }
            hl.type.yield %3 : !hl.lvalue<!hl.int>
          } : !hl.int
          %2 = hl.stmt.expr : !hl.typeof.expr<"(x)"> {
            %3 = hl.var @x : !hl.lvalue<!hl.int> = {
              %7 = hl.const #core.integer<0> : !hl.int
              hl.value.yield %7 : !hl.int
            }
            %4 = hl.var @y : !hl.lvalue<!hl.typeof.expr<"(x)">> = {
              %7 = hl.ref %3 : (!hl.lvalue<!hl.int>) -> !hl.lvalue<!hl.int>
              %8 = hl.implicit_cast %7 LValueToRValue : !hl.lvalue<!hl.int> -> !hl.int
              hl.value.yield %8 : !hl.int
            }
            %5 = hl.ref %4 : (!hl.lvalue<!hl.typeof.expr<"(x)">>) -> !hl.lvalue<!hl.typeof.expr<"(x)">>
            %6 = hl.implicit_cast %5 LValueToRValue : !hl.lvalue<!hl.typeof.expr<"(x)">> -> !hl.typeof.expr<"(x)">
            hl.value.yield %6 : !hl.typeof.expr<"(x)">
          }

The issue is unsupported DeclRefExpr in the typeof.expr region, that refers to x that is in the scope of the stmt.expr.
This is caused by visiting the return type of the stmt.expr

Steps to Reproduce

Run vast-front to hl

@Jezurko Jezurko added the bug Something isn't working label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant