521
521
def from_any(a):
522
522
a, r0, r1 :: object
523
523
r2 :: bool
524
- x, r3 :: object
524
+ r3 :: object
525
525
r4 :: bool
526
- y, r5 :: object
526
+ x, y, r5 :: object
527
527
r6 :: bool
528
528
L0:
529
529
r0 = PyObject_GetIter(a)
@@ -533,13 +533,13 @@ L1:
533
533
r2 = raise ValueError('not enough values to unpack')
534
534
unreachable
535
535
L2:
536
- x = r1
537
536
r3 = PyIter_Next(r0)
538
537
if is_error(r3) goto L3 else goto L4
539
538
L3:
540
539
r4 = raise ValueError('not enough values to unpack')
541
540
unreachable
542
541
L4:
542
+ x = r1
543
543
y = r3
544
544
r5 = PyIter_Next(r0)
545
545
if is_error(r5) goto L6 else goto L5
577
577
def from_any(a):
578
578
a, r0, r1 :: object
579
579
r2 :: bool
580
- r3, x :: int
581
- r4 :: object
582
- r5 :: bool
580
+ r3 :: object
581
+ r4 :: bool
582
+ r5, x :: int
583
583
y, r6 :: object
584
584
r7 :: bool
585
585
L0:
@@ -590,15 +590,15 @@ L1:
590
590
r2 = raise ValueError('not enough values to unpack')
591
591
unreachable
592
592
L2:
593
- r3 = unbox(int, r1)
594
- x = r3
595
- r4 = PyIter_Next(r0)
596
- if is_error(r4) goto L3 else goto L4
593
+ r3 = PyIter_Next(r0)
594
+ if is_error(r3) goto L3 else goto L4
597
595
L3:
598
- r5 = raise ValueError('not enough values to unpack')
596
+ r4 = raise ValueError('not enough values to unpack')
599
597
unreachable
600
598
L4:
601
- y = r4
599
+ r5 = unbox(int, r1)
600
+ x = r5
601
+ y = r3
602
602
r6 = PyIter_Next(r0)
603
603
if is_error(r6) goto L6 else goto L5
604
604
L5:
607
607
L6:
608
608
return 1
609
609
610
+ [case testStarUnpack]
611
+ from typing import Any, List, Iterator
612
+
613
+ it: Iterator = iter(['x', 'y', 'z1', 'z2', 'z3', 'u', 'w'])
614
+
615
+ def f(a: Any) -> None:
616
+ a.x, a.y, *a.z, a.u, a.w = it
617
+ [out]
618
+ def f(a):
619
+ a :: object
620
+ r0 :: dict
621
+ r1 :: str
622
+ r2, r3, r4 :: object
623
+ r5 :: bool
624
+ r6 :: object
625
+ r7 :: bool
626
+ r8 :: str
627
+ r9 :: int32
628
+ r10 :: bit
629
+ r11 :: str
630
+ r12 :: int32
631
+ r13 :: bit
632
+ r14 :: list
633
+ r15 :: ptr
634
+ r16 :: int64
635
+ r17 :: short_int
636
+ r18 :: bit
637
+ r19 :: bool
638
+ r20, r21 :: object
639
+ r22 :: str
640
+ r23 :: int32
641
+ r24 :: bit
642
+ r25 :: str
643
+ r26 :: int32
644
+ r27 :: bit
645
+ r28 :: str
646
+ r29 :: int32
647
+ r30 :: bit
648
+ L0:
649
+ r0 = __main__.globals :: static
650
+ r1 = 'it'
651
+ r2 = CPyDict_GetItem(r0, r1)
652
+ r3 = PyObject_GetIter(r2)
653
+ r4 = PyIter_Next(r3)
654
+ if is_error(r4) goto L1 else goto L2
655
+ L1:
656
+ r5 = raise ValueError('not enough values to unpack')
657
+ unreachable
658
+ L2:
659
+ r6 = PyIter_Next(r3)
660
+ if is_error(r6) goto L3 else goto L4
661
+ L3:
662
+ r7 = raise ValueError('not enough values to unpack')
663
+ unreachable
664
+ L4:
665
+ r8 = 'x'
666
+ r9 = PyObject_SetAttr(a, r8, r4)
667
+ r10 = r9 >= 0 :: signed
668
+ r11 = 'y'
669
+ r12 = PyObject_SetAttr(a, r11, r6)
670
+ r13 = r12 >= 0 :: signed
671
+ r14 = PySequence_List(r3)
672
+ r15 = get_element_ptr r14 ob_size :: PyVarObject
673
+ r16 = load_mem r15 :: int64*
674
+ keep_alive r14
675
+ r17 = r16 << 1
676
+ r18 = 4 <= r17 :: signed
677
+ if r18 goto L6 else goto L5 :: bool
678
+ L5:
679
+ r19 = raise ValueError('not enough values to unpack')
680
+ unreachable
681
+ L6:
682
+ r20 = CPyList_PopLast(r14)
683
+ r21 = CPyList_PopLast(r14)
684
+ r22 = 'w'
685
+ r23 = PyObject_SetAttr(a, r22, r20)
686
+ r24 = r23 >= 0 :: signed
687
+ r25 = 'u'
688
+ r26 = PyObject_SetAttr(a, r25, r21)
689
+ r27 = r26 >= 0 :: signed
690
+ r28 = 'z'
691
+ r29 = PyObject_SetAttr(a, r28, r14)
692
+ r30 = r29 >= 0 :: signed
693
+ return 1
694
+
610
695
[case testMultiAssignmentNested]
611
696
from typing import Tuple, Any, List
612
697
0 commit comments