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

Implement visitor: NamedExpr #37

Merged
merged 5 commits into from
Jan 17, 2022
Merged

Conversation

namannimmo10
Copy link
Collaborator

Reference code:

def test_namedexpr():
    a: i32
    x: i32
    y: i32

    # check 1
    x = (y := 0)

    # check 2
    if a := ord('3'):
        x = 1

    # check 3
    while a := 1:
        y = 1

ASR:

(TranslationUnit
   (SymbolTable
      1
      {
         test_namedexpr:
            (Subroutine
               (SymbolTable
                  2
                  {
                     a:
                        (Variable
                           2
                           a
                           Local () ()
                           Default
                           (Integer 4 [])
                           Source
                           Public
                           Required .false.),
                     x:
                        (Variable
                           2
                           x
                           Local () ()
                           Default
                           (Integer 4 [])
                           Source
                           Public
                           Required .false.),
                     y:
                        (Variable
                           2
                           y
                           Local () ()
                           Default
                           (Integer 4 [])
                           Source
                           Public
                           Required .false.)
                  })
               test_namedexpr [] [
               (=
                  (Var 2 x)
                  (NamedExpr
                     (Var 2 y) (ConstantInteger 0
                     (Integer 4 []))
                     (Integer 4 [])) ())
               (If
                  (NamedExpr
                     (Var 2 a) (ConstantInteger 51
                     (Integer 4 []))
                     (Integer 4 [])) [
                  (=
                     (Var 2 x) (ConstantInteger 1
                     (Integer 4 [])) ())] [])
               (WhileLoop
                  (NamedExpr
                     (Var 2 a) (ConstantInteger 1
                     (Integer 4 []))
                     (Integer 4 [])) [
                  (=
                     (Var 2 y) (ConstantInteger 1
                     (Integer 4 [])) ())])]
               Source
               Public
               Implementation () .false. .false.)
      })
   [])

@certik
Copy link
Contributor

certik commented Jan 17, 2022

I guess just rerunning the tests does not fix them (apparently the CI tests are not running on a merge commit?). But rebasing on top of the latest main should fix this, so I did that.

@certik
Copy link
Contributor

certik commented Jan 17, 2022

Ok, so the CI failure is real, the C++ backend does not support this yet. I think we have to separate the C++ backend tests from new improvements in ASR.

@namannimmo10
Copy link
Collaborator Author

Ok, so the CI failure is real, the C++ backend does not support this yet. I think we have to separate the C++ backend tests from new improvements in ASR.

I'm working on it.

@certik
Copy link
Contributor

certik commented Jan 17, 2022

I pushed in the fix, now it should work.

@namannimmo10
Copy link
Collaborator Author

Awesome, thanks!

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

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

I think it works now. After the CI passes, you can merge it.

@namannimmo10 namannimmo10 merged commit c88f45d into lcompilers:main Jan 17, 2022
@namannimmo10 namannimmo10 deleted the namedexpr branch January 17, 2022 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants