@@ -60,11 +60,15 @@ impl std::fmt::Display for UntypedValue<'_> {
6060pub struct UntypedFuncCall < ' source > {
6161 source : Cow < ' source , str > ,
6262 name : Node ,
63- params : Node ,
63+ params : Option < Node > ,
6464}
6565
6666impl < ' source > UntypedFuncCall < ' source > {
67- pub ( crate ) fn new ( source : impl Into < Cow < ' source , str > > , name : Node , params : Node ) -> Self {
67+ pub ( crate ) fn new (
68+ source : impl Into < Cow < ' source , str > > ,
69+ name : Node ,
70+ params : Option < Node > ,
71+ ) -> Self {
6872 Self {
6973 source : source. into ( ) ,
7074 name,
@@ -100,8 +104,10 @@ impl<'source> UntypedFuncCall<'source> {
100104 }
101105
102106 /// Returns the function parameters node.
103- pub fn params_node ( & self ) -> & Node {
104- & self . params
107+ ///
108+ /// Returns `None` if the function call has no parameters.
109+ pub fn params_node ( & self ) -> Option < & Node > {
110+ self . params . as_ref ( )
105111 }
106112
107113 /// Returns the function name.
@@ -117,14 +123,20 @@ impl<'source> UntypedFuncCall<'source> {
117123 & self ,
118124 types : impl IntoIterator < Item = & ' types V :: Type > ,
119125 ) -> Result < Vec < V > , ParserError > {
120- self . params . to_wasm_params ( types, self . source ( ) )
126+ match & self . params {
127+ Some ( params) => params. to_wasm_params ( types, self . source ( ) ) ,
128+ None => Ok ( vec ! [ ] ) ,
129+ }
121130 }
122131}
123132
124133impl std:: fmt:: Display for UntypedFuncCall < ' _ > {
125134 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
126135 f. write_str ( self . name . slice ( & self . source ) ) ?;
127- fmt_node ( f, & self . params , & self . source )
136+ match & self . params {
137+ Some ( params) => fmt_node ( f, params, & self . source ) ,
138+ None => f. write_str ( "()" ) ,
139+ }
128140 }
129141}
130142
0 commit comments