File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
compiler/noirc_frontend/src Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -329,15 +329,14 @@ impl<'context> Elaborator<'context> {
329329 push_arg ( Value :: TraitDefinition ( trait_id) ) ;
330330 } else {
331331 let ( expr_id, expr_type) = interpreter. elaborator . elaborate_expression ( arg) ;
332- push_arg ( interpreter. evaluate ( expr_id) ?) ;
333-
334332 if let Err ( UnificationError ) = expr_type. unify ( param_type) {
335333 return Err ( InterpreterError :: TypeMismatch {
336334 expected : param_type. clone ( ) ,
337335 actual : expr_type,
338336 location : arg_location,
339337 } ) ;
340338 }
339+ push_arg ( interpreter. evaluate ( expr_id) ?) ;
341340 } ;
342341 }
343342
Original file line number Diff line number Diff line change @@ -141,3 +141,23 @@ fn errors_if_macros_inject_functions_with_name_collisions() {
141141 ) if contents == "foo"
142142 ) ) ;
143143}
144+
145+ #[ test]
146+ fn uses_correct_type_for_attribute_arguments ( ) {
147+ let src = r#"
148+ #[foo(32)]
149+ comptime fn foo(_f: FunctionDefinition, i: u32) {
150+ let y: u32 = 1;
151+ let _ = y == i;
152+ }
153+
154+ #[bar([0; 2])]
155+ comptime fn bar(_f: FunctionDefinition, i: [u32; 2]) {
156+ let y: u32 = 1;
157+ let _ = y == i[0];
158+ }
159+
160+ fn main() {}
161+ "# ;
162+ assert_no_errors ( src) ;
163+ }
You can’t perform that action at this time.
0 commit comments