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

Python TSG: Error when a lambda does not have a parameter list #440

Open
ghost opened this issue Jun 7, 2024 · 0 comments
Open

Python TSG: Error when a lambda does not have a parameter list #440

ghost opened this issue Jun 7, 2024 · 0 comments

Comments

@ghost
Copy link

ghost commented Jun 7, 2024

When a Python lambda does not have an parameter list, the current TSG fails.

Example

The rules currently fail for the following CST.

(lambda [207, 32] - [207, 69]
  body: (call [207, 40] - [207, 69]
    function: (attribute [207, 40] - [207, 53]
      object: (identifier [207, 40] - [207, 48])
      attribute: (identifier [207, 49] - [207, 53]))
    arguments: (argument_list [207, 53] - [207, 69]
      (list_splat [207, 54] - [207, 68]
        (attribute [207, 55] - [207, 68]
          object: (identifier [207, 55] - [207, 63])
          attribute: (identifier [207, 64] - [207, 68]))))))))))))))

Suggested change

[
  (function_definition
--    parameters: (_) @params
++    parameters: (_)? @params
    body: (_) @body
  ) @func
  (lambda
--    parameters: (_) @params
++    parameters: (_)? @params
    body: (_) @body
  )@func
] {
  node @func.call
  node return_value
  node drop_scope

  edge @func.call -> return_value

++  if some @params {
    edge @body.before_scope -> @params.after_scope
++  }
  edge @body.before_scope -> drop_scope
  edge drop_scope -> @func.bottom
  attr (drop_scope) type = "drop_scopes"
  attr (@func.call) pop_scoped_symbol = "()"
++  if some @params {
    edge @params.before_scope -> JUMP_TO_SCOPE_NODE
++  }
  attr (return_value) is_exported
  let @func.function_returns = return_value
}
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

No branches or pull requests

0 participants