@@ -759,32 +759,39 @@ inherit .parent_module
759759
760760(with_clause) {}
761761
762- (function_definition
763- name: (identifier) @name) {
764- attr (@name.def) node_definition = @name
765- }
766-
767- (function_definition
768- name: (identifier) @name
769- parameters: (parameters) @params
770- body: (block) @body) @func
771- {
772- node call
773- node drop_scope
762+ [
763+ (function_definition
764+ parameters: (_) @params
765+ body: (_) @body
766+ ) @func
767+ (lambda
768+ parameters: (_) @params
769+ body: (_) @body
770+ )@func
771+ ] {
772+ node @func.call
774773 node return_value
774+ node drop_scope
775775
776- attr (@name.def) definiens_node = @func
777- edge @func.after_scope -> @name.def
778- edge @name.def -> call
779- edge call -> return_value
776+ edge @func.call -> return_value
780777 edge @body.before_scope -> @params.after_scope
781778 edge @body.before_scope -> drop_scope
782779 edge drop_scope -> @func.bottom
783780 attr (drop_scope) type = "drop_scopes"
784- attr (call) pop_scoped_symbol = "()"
781+ attr (@func. call) pop_scoped_symbol = "()"
785782 edge @params.before_scope -> JUMP_TO_SCOPE_NODE
786783 attr (return_value) is_exported
787784 let @func.function_returns = return_value
785+ }
786+
787+ (function_definition
788+ name: (identifier) @name
789+ body: (_) @body
790+ ) @func {
791+ attr (@name.def) node_definition = @name
792+ attr (@name.def) definiens_node = @func
793+ edge @func.after_scope -> @name.def
794+ edge @name.def -> @func.call
788795
789796 ; Prevent functions defined inside of method bodies from being treated like methods
790797 let @body.class_self_scope = #null
@@ -802,8 +809,10 @@ inherit .parent_module
802809 attr (@param.output) push_node = @param
803810}
804811
805- (parameters
806- (_) @param) @params
812+ [
813+ (parameters (_) @param) @params
814+ (lambda_parameters (_) @param) @params
815+ ]
807816{
808817 node @param.param_index
809818 node @param.param_name
@@ -954,6 +963,18 @@ inherit .parent_module
954963;;
955964;; Expressions
956965
966+ (lambda
967+ body: (_) @body
968+ )@lam {
969+ ;; TODO Unify .before_scope, .local_scope, and .input to simplify
970+ ;; uniform treatment of lambdas and function definitions.
971+ node @body.before_scope
972+ let @body.local_scope = @body.before_scope
973+ edge @body.input -> @body.before_scope
974+
975+ edge @lam.output -> @lam.call
976+ }
977+
957978(conditional_expression) {}
958979
959980(named_expression) {}
0 commit comments