File tree Expand file tree Collapse file tree 2 files changed +48
-6
lines changed
crates/cairo-lang-semantic/src/expr Expand file tree Collapse file tree 2 files changed +48
-6
lines changed Original file line number Diff line number Diff line change @@ -3818,19 +3818,15 @@ fn member_access_expr<'db>(
38183818 derefed_expr =
38193819 ExprAndId { expr : cur_expr. clone ( ) , id : ctx. arenas . exprs . alloc ( cur_expr) } ;
38203820 }
3821- let ( _ , long_ty) =
3821+ let ( n_snapshots , long_ty) =
38223822 finalized_snapshot_peeled_ty ( ctx, derefed_expr. ty ( ) , rhs_syntax. stable_ptr ( db) ) ?;
38233823 let derefed_expr_concrete_struct_id = match long_ty {
38243824 TypeLongId :: Concrete ( ConcreteTypeId :: Struct ( concrete_struct_id) ) => {
38253825 concrete_struct_id
38263826 }
38273827 _ => unreachable ! ( ) ,
38283828 } ;
3829- let ty = if !deref_functions. is_empty ( ) {
3830- member. ty
3831- } else {
3832- wrap_in_snapshots ( ctx. db , member. ty , n_snapshots)
3833- } ;
3829+ let ty = wrap_in_snapshots ( ctx. db , member. ty , n_snapshots) ;
38343830 let mut final_expr = Expr :: MemberAccess ( ExprMemberAccess {
38353831 expr : derefed_expr. id ,
38363832 concrete_struct_id : derefed_expr_concrete_struct_id,
Original file line number Diff line number Diff line change @@ -202,3 +202,49 @@ error: Type `test::S1` cannot be dereferenced
202202 --> lib.cairo:13:14
203203 let _ = (*a);
204204 ^
205+
206+ //! > ==========================================================================
207+
208+ //! > Final deref return values should decide the number of snapshots - single snapshot.
209+
210+ //! > test_runner_name
211+ test_function_diagnostics(expect_diagnostics: false)
212+
213+ //! > function_code
214+ fn foo(a: Box<@A>) -> @usize {
215+ a.b
216+ }
217+
218+ //! > function_name
219+ foo
220+
221+ //! > module_code
222+ struct A {
223+ a: usize,
224+ b: usize,
225+ }
226+
227+ //! > expected_diagnostics
228+
229+ //! > ==========================================================================
230+
231+ //! > Final deref return values should decide the number of snapshots - multiple snapshots.
232+
233+ //! > test_runner_name
234+ test_function_diagnostics(expect_diagnostics: false)
235+
236+ //! > function_code
237+ fn foo(a: Box<@@@A>) -> @@@usize {
238+ a.b
239+ }
240+
241+ //! > function_name
242+ foo
243+
244+ //! > module_code
245+ struct A {
246+ a: usize,
247+ b: usize,
248+ }
249+
250+ //! > expected_diagnostics
You can’t perform that action at this time.
0 commit comments