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 translation for PM_LAMBDA_NODE #125

Closed
1 task done
Tracked by #36
amomchilov opened this issue Aug 2, 2024 · 2 comments · Fixed by #285
Closed
1 task done
Tracked by #36

Implement translation for PM_LAMBDA_NODE #125

amomchilov opened this issue Aug 2, 2024 · 2 comments · Fixed by #285
Assignees

Comments

@amomchilov
Copy link

amomchilov commented Aug 2, 2024

Special considerations:

@st0012
Copy link
Member

st0012 commented Oct 14, 2024

Sorbet parser's way of parsing lambda is pretty surprising to me.

Given

-> { 123 }

Prism gives:

@ ProgramNode (location: (1,0)-(1,10))
├── flags: ∅
├── locals: []
└── statements:
    @ StatementsNode (location: (1,0)-(1,10))
    ├── flags: ∅
    └── body: (length: 1)
        └── @ LambdaNode (location: (1,0)-(1,10))
            ├── flags: newline
            ├── locals: []
            ├── operator_loc: (1,0)-(1,2) = "->"
            ├── opening_loc: (1,3)-(1,4) = "{"
            ├── closing_loc: (1,9)-(1,10) = "}"
            ├── parameters: ∅
            └── body:
                @ StatementsNode (location: (1,5)-(1,8))
                ├── flags: ∅
                └── body: (length: 1)
                    └── @ IntegerNode (location: (1,5)-(1,8))
                        ├── flags: newline, static_literal, decimal
                        └── value: 123

But Sorbet's legacy parser give:

Block {
  send = Send {
    receiver = Const {
      scope = NULL
      name = <C <U Kernel>>
    }
    method = <U lambda>
    args = [
    ]
  }
  args = NULL
  body = Integer {
    val = "123"
  }
}

I think the structure reverse part is similar to method calls with block, but I'm not sure if there's a good way to populate the constant receiver. I think we haven't had any similar cases in other nodes?

@amomchilov
Copy link
Author

@st0012 I think you can use core::Names::Constants::Kernel() for the receiver, and core::Names::lambda() for the method name.

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 a pull request may close this issue.

2 participants