@@ -634,6 +634,47 @@ def _lint_node(
634634 f"Error: '{ name } ' is not a defined body. Only bodies may be called with '{ state .attribute_name } ' { location } "
635635 )
636636 return 1
637+ if node .type == "attribute_name" and state .promise_type and state .attribute_name :
638+ promise_type_data = syntax_data .BUILTIN_PROMISE_TYPES .get (
639+ state .promise_type , {}
640+ )
641+ promise_type_attrs = promise_type_data .get ("attributes" , {})
642+ if state .attribute_name not in promise_type_attrs :
643+ _highlight_range (node , lines )
644+ print (
645+ f"Error: Invalid attribute '{ state .attribute_name } ' for promise type '{ state .promise_type } ' { location } "
646+ )
647+ return 1
648+ if (
649+ state .block_keyword == "promise"
650+ and node .type == "attribute_name"
651+ and state .attribute_name
652+ not in (
653+ None ,
654+ "path" ,
655+ "interpreter" ,
656+ )
657+ ):
658+ _highlight_range (node , lines )
659+ print (
660+ f"Error: Invalid attribute name '{ state .attribute_name } ' in '{ state .block_name } ' custom promise type definition { location } "
661+ )
662+ return 1
663+ if node .type == "call" :
664+ call , _ , * args , _ = node .children # f ( a1 , a2 , a..N )
665+ call = _text (call )
666+ args = list (filter ("," .__ne__ , iter (_text (x ) for x in args )))
667+
668+ if call in syntax_data .BUILTIN_FUNCTIONS :
669+ variadic = syntax_data .BUILTIN_FUNCTIONS .get (call , {}).get ("variadic" , True )
670+ params = syntax_data .BUILTIN_FUNCTIONS .get (call , {}).get ("parameters" , {})
671+ if not variadic and (len (params ) != len (args )):
672+ _highlight_range (node , lines )
673+ print (
674+ f"Error: Expected { len (params )} arguments, received { len (args )} { location } "
675+ )
676+ return 1
677+ # TODO: Handle variadic functions with varying number of required arguments (0-N, 1-N, 2-N and so on)
637678 return 0
638679
639680
0 commit comments