@@ -7,7 +7,7 @@ use crate::ast::{
77} ;
88use crate :: hir:: def_collector:: errors:: DefCollectorErrorKind ;
99use crate :: macros_api:: StructId ;
10- use crate :: node_interner:: { ExprId , InternedExpressionKind , QuotedTypeId } ;
10+ use crate :: node_interner:: { ExprId , InternedExpressionKind , InternedStatementKind , QuotedTypeId } ;
1111use crate :: token:: { Attributes , FunctionAttribute , Token , Tokens } ;
1212use crate :: { Kind , Type } ;
1313use acvm:: { acir:: AcirField , FieldElement } ;
@@ -48,6 +48,10 @@ pub enum ExpressionKind {
4848 // The actual ExpressionKind can be retrieved with a NodeInterner.
4949 Interned ( InternedExpressionKind ) ,
5050
51+ /// Interned statements are allowed to be parsed as expressions in case they resolve
52+ /// to an StatementKind::Expression or StatementKind::Semi.
53+ InternedStatement ( InternedStatementKind ) ,
54+
5155 Error ,
5256}
5357
@@ -200,9 +204,11 @@ impl ExpressionKind {
200204 ExpressionKind :: Literal ( Literal :: FmtStr ( contents) )
201205 }
202206
203- pub fn constructor ( ( type_name, fields) : ( Path , Vec < ( Ident , Expression ) > ) ) -> ExpressionKind {
207+ pub fn constructor (
208+ ( typ, fields) : ( UnresolvedType , Vec < ( Ident , Expression ) > ) ,
209+ ) -> ExpressionKind {
204210 ExpressionKind :: Constructor ( Box :: new ( ConstructorExpression {
205- type_name ,
211+ typ ,
206212 fields,
207213 struct_type : None ,
208214 } ) )
@@ -536,7 +542,7 @@ pub struct MethodCallExpression {
536542
537543#[ derive( Debug , PartialEq , Eq , Clone ) ]
538544pub struct ConstructorExpression {
539- pub type_name : Path ,
545+ pub typ : UnresolvedType ,
540546 pub fields : Vec < ( Ident , Expression ) > ,
541547
542548 /// This may be filled out during macro expansion
@@ -615,6 +621,7 @@ impl Display for ExpressionKind {
615621 write ! ( f, "quote {{ {} }}" , tokens. join( " " ) )
616622 }
617623 AsTraitPath ( path) => write ! ( f, "{path}" ) ,
624+ InternedStatement ( _) => write ! ( f, "?InternedStatement" ) ,
618625 }
619626 }
620627}
@@ -717,7 +724,7 @@ impl Display for ConstructorExpression {
717724 let fields =
718725 self . fields . iter ( ) . map ( |( ident, expr) | format ! ( "{ident}: {expr}" ) ) . collect :: < Vec < _ > > ( ) ;
719726
720- write ! ( f, "({} {{ {} }})" , self . type_name , fields. join( ", " ) )
727+ write ! ( f, "({} {{ {} }})" , self . typ , fields. join( ", " ) )
721728 }
722729}
723730
0 commit comments