@@ -63,7 +63,7 @@ pub fn expr_list(
6363 return Ok ( ExpressionAttributes {
6464 typ : Type :: Array ( Array {
6565 size : 0 ,
66- inner : expected_type. map_or ( Base :: Unit , |arr| arr. inner ) ,
66+ inner : expected_type. map_or ( Box :: new ( Base :: Unit . into ( ) ) , |arr| arr. inner . clone ( ) ) ,
6767 } ) ,
6868 location : Location :: Memory ,
6969 move_location : None ,
@@ -73,9 +73,8 @@ pub fn expr_list(
7373
7474 let inner_type = if let Some ( expected) = expected_type {
7575 for elt in elts {
76- let element_attributes =
77- assignable_expr ( context, elt, Some ( & Type :: Base ( expected. inner ) ) ) ?;
78- if element_attributes. typ != Type :: Base ( expected. inner ) {
76+ let element_attributes = assignable_expr ( context, elt, Some ( & expected. inner ) ) ?;
77+ if & element_attributes. typ != expected. inner . as_ref ( ) {
7978 context. type_error (
8079 "type mismatch" ,
8180 elt. span ,
@@ -84,11 +83,11 @@ pub fn expr_list(
8483 ) ;
8584 }
8685 }
87- expected. inner
86+ expected. inner . clone ( )
8887 } else {
8988 let first_attr = assignable_expr ( context, & elts[ 0 ] , None ) ?;
9089 let inner = match first_attr. typ {
91- Type :: Base ( base) => base,
90+ Type :: Base ( base) => base. into ( ) ,
9291 _ => {
9392 return Err ( FatalError :: new ( context. error (
9493 "arrays can only hold primitive types" ,
@@ -119,7 +118,7 @@ pub fn expr_list(
119118 ) ;
120119 }
121120 }
122- inner
121+ Box :: new ( inner)
123122 } ;
124123
125124 // TODO: Right now we are only supporting Base type arrays
@@ -1011,25 +1010,23 @@ fn expr_call_builtin_function(
10111010 expect_no_label_on_arg ( context, args, 0 ) ;
10121011
10131012 if let Some ( arg_typ) = argument_attributes. first ( ) . map ( |attr| & attr. typ ) {
1014- if !matches ! (
1015- arg_typ,
1016- Type :: Array ( Array {
1017- inner: Base :: Numeric ( Integer :: U8 ) ,
1018- ..
1019- } )
1020- ) {
1021- context. fancy_error (
1022- & format ! (
1023- "`{}` can not be used as an argument to `{}`" ,
1024- arg_typ,
1025- function. as_ref( ) ,
1026- ) ,
1027- vec ! [ Label :: primary( args. span, "wrong type" ) ] ,
1028- vec ! [ format!(
1029- "Note: `{}` expects a byte array argument" ,
1030- function. as_ref( )
1031- ) ] ,
1032- ) ;
1013+ match arg_typ {
1014+ Type :: Array ( Array { inner, .. } )
1015+ if inner. as_ref ( ) == & Type :: Base ( Base :: Numeric ( Integer :: U8 ) ) => { }
1016+ _ => {
1017+ context. fancy_error (
1018+ & format ! (
1019+ "`{}` can not be used as an argument to `{}`" ,
1020+ arg_typ,
1021+ function. as_ref( ) ,
1022+ ) ,
1023+ vec ! [ Label :: primary( args. span, "wrong type" ) ] ,
1024+ vec ! [ format!(
1025+ "Note: `{}` expects a byte array argument" ,
1026+ function. as_ref( )
1027+ ) ] ,
1028+ ) ;
1029+ }
10331030 }
10341031 } ;
10351032 ExpressionAttributes :: new ( Type :: Base ( U256 ) , Location :: Value )
@@ -1509,7 +1506,7 @@ fn expr_call_builtin_value_method(
15091506 Ok ( (
15101507 ExpressionAttributes :: new (
15111508 Type :: Array ( Array {
1512- inner : Base :: Numeric ( Integer :: U8 ) ,
1509+ inner : Box :: new ( Base :: Numeric ( Integer :: U8 ) . into ( ) ) ,
15131510 size : struct_. id . fields ( context. db ( ) ) . len ( ) * 32 ,
15141511 } ) ,
15151512 Location :: Memory ,
@@ -1531,7 +1528,7 @@ fn expr_call_builtin_value_method(
15311528 Ok ( (
15321529 ExpressionAttributes :: new (
15331530 Type :: Array ( Array {
1534- inner : Base :: Numeric ( Integer :: U8 ) ,
1531+ inner : Box :: new ( Base :: Numeric ( Integer :: U8 ) . into ( ) ) ,
15351532 size : tuple. items . len ( ) * 32 ,
15361533 } ) ,
15371534 Location :: Memory ,
0 commit comments