core: Inferencer fold_stmt() on StmtKind::Assign should not force unify value_ty with target_ty for __setitem__ assignments. #460

Closed
opened 2024-07-16 12:19:04 +08:00 by lyken · 1 comment
Collaborator

value_ty does not have to be the same as target_ty in general (note that ndarray subscript assignment depends on #411):

arr = np_zeros((3, 4))
another_arr = np_ones((2,))

arr[:,1:3] = another_arr
# not ok
# LHS type == ndarray[2; float64]
# RHS type == ndarray[1; float64]

arr[:] = 1
# not ok
# LHS type == ndarray[2; float64]
# RHS type = float64

If this is rectified, Generator::gen_assign should add an extra parameter value_ty: Type.

Everything here may go the same for AugAssign.

`value_ty` does not have to be the same as `target_ty` in general (note that ndarray subscript assignment depends on https://git.m-labs.hk/M-Labs/nac3/issues/411): ```python arr = np_zeros((3, 4)) another_arr = np_ones((2,)) arr[:,1:3] = another_arr # not ok # LHS type == ndarray[2; float64] # RHS type == ndarray[1; float64] arr[:] = 1 # not ok # LHS type == ndarray[2; float64] # RHS type = float64 ``` If this is rectified, `Generator::gen_assign` should add an extra parameter `value_ty: Type`. Everything here may go the same for `AugAssign`.
lyken referenced this issue from a commit 2024-07-16 13:05:21 +08:00
lyken changed title from core: Inferencer `fold_stmt()` on `StmtKind::Assign` should not force unify `value_ty` with `target_ty`. to core: Inferencer `fold_stmt()` on `StmtKind::Assign` should not force unify `value_ty` with `target_ty` for `__setitem__` assignments. 2024-07-31 10:48:08 +08:00
Author
Collaborator

#482 is a more general issue than this. Closing.

https://git.m-labs.hk/M-Labs/nac3/issues/482 is a more general issue than this. Closing.
lyken closed this issue 2024-07-31 10:51:02 +08:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#460
No description provided.