@@ -19110,6 +19110,44 @@ function* eachPatternOperand(pattern) {
19110
19110
}
19111
19111
}
19112
19112
}
19113
+ function* eachPatternItem(pattern) {
19114
+ switch (pattern.kind) {
19115
+ case 'ArrayPattern': {
19116
+ for (const item of pattern.items) {
19117
+ if (item.kind === 'Identifier') {
19118
+ yield item;
19119
+ }
19120
+ else if (item.kind === 'Spread') {
19121
+ yield item;
19122
+ }
19123
+ else if (item.kind === 'Hole') {
19124
+ continue;
19125
+ }
19126
+ else {
19127
+ assertExhaustive$1(item, `Unexpected item kind \`${item.kind}\``);
19128
+ }
19129
+ }
19130
+ break;
19131
+ }
19132
+ case 'ObjectPattern': {
19133
+ for (const property of pattern.properties) {
19134
+ if (property.kind === 'ObjectProperty') {
19135
+ yield property.place;
19136
+ }
19137
+ else if (property.kind === 'Spread') {
19138
+ yield property;
19139
+ }
19140
+ else {
19141
+ assertExhaustive$1(property, `Unexpected item kind \`${property.kind}\``);
19142
+ }
19143
+ }
19144
+ break;
19145
+ }
19146
+ default: {
19147
+ assertExhaustive$1(pattern, `Unexpected pattern kind \`${pattern.kind}\``);
19148
+ }
19149
+ }
19150
+ }
19113
19151
function mapInstructionLValues(instr, fn) {
19114
19152
switch (instr.value.kind) {
19115
19153
case 'DeclareLocal':
@@ -41879,20 +41917,34 @@ function computeSignatureForInstruction(context, env, instr) {
41879
41917
break;
41880
41918
}
41881
41919
case 'Destructure': {
41882
- for (const patternLValue of eachInstructionValueLValue(value)) {
41883
- if (isPrimitiveType(patternLValue.identifier)) {
41920
+ for (const patternItem of eachPatternItem(value.lvalue.pattern)) {
41921
+ const place = patternItem.kind === 'Identifier' ? patternItem : patternItem.place;
41922
+ if (isPrimitiveType(place.identifier)) {
41884
41923
effects.push({
41885
41924
kind: 'Create',
41886
- into: patternLValue ,
41925
+ into: place ,
41887
41926
value: ValueKind.Primitive,
41888
41927
reason: ValueReason.Other,
41889
41928
});
41890
41929
}
41891
- else {
41930
+ else if (patternItem.kind === 'Identifier') {
41892
41931
effects.push({
41893
41932
kind: 'CreateFrom',
41894
41933
from: value.value,
41895
- into: patternLValue,
41934
+ into: place,
41935
+ });
41936
+ }
41937
+ else {
41938
+ effects.push({
41939
+ kind: 'Create',
41940
+ into: place,
41941
+ reason: ValueReason.Other,
41942
+ value: ValueKind.Mutable,
41943
+ });
41944
+ effects.push({
41945
+ kind: 'Capture',
41946
+ from: value.value,
41947
+ into: place,
41896
41948
});
41897
41949
}
41898
41950
}
@@ -46561,6 +46613,12 @@ function* generateInstructionTypes(env, names, instr) {
46561
46613
},
46562
46614
});
46563
46615
}
46616
+ else if (item.kind === 'Spread') {
46617
+ yield equation(item.place.identifier.type, {
46618
+ kind: 'Object',
46619
+ shapeId: BuiltInArrayId,
46620
+ });
46621
+ }
46564
46622
else {
46565
46623
break;
46566
46624
}
0 commit comments