Skip to content

Commit 1cbe393

Browse files
authored
fix: Types of small integer constants should always set a current type (AssemblyScript#2132)
1 parent 70013e9 commit 1cbe393

File tree

77 files changed

+289
-134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+289
-134
lines changed

src/compiler.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3392,14 +3392,8 @@ export class Compiler extends DiagnosticEmitter {
33923392
): ExpressionRef {
33933393
assert(element.is(CommonFlags.INLINED | CommonFlags.RESOLVED));
33943394
var type = element.type;
3395-
switch (
3396-
!(constraints & (Constraints.CONV_IMPLICIT | Constraints.CONV_EXPLICIT)) &&
3397-
type.isIntegerValue &&
3398-
contextualType.isIntegerValue &&
3399-
type.size < contextualType.size
3400-
? (this.currentType = contextualType).kind // essentially precomputes a (sign-)extension
3401-
: (this.currentType = type).kind
3402-
) {
3395+
this.currentType = type;
3396+
switch (type.kind) {
34033397
case TypeKind.I8:
34043398
case TypeKind.I16: {
34053399
let shift = type.computeSmallIntegerShift(Type.i32);

tests/compiler/binary.untouched.wat

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -722,10 +722,12 @@
722722
local.set $11
723723
local.get $11
724724
i64.const 52
725-
i64.const 7
725+
i32.const 7
726+
i64.extend_i32_s
726727
i64.sub
727728
i64.shr_u
728-
i64.const 127
729+
i32.const 127
730+
i64.extend_i32_s
729731
i64.and
730732
i32.wrap_i64
731733
local.set $12
@@ -1048,7 +1050,8 @@
10481050
f64.add
10491051
local.set $28
10501052
local.get $14
1051-
i64.const 127
1053+
i32.const 127
1054+
i64.extend_i32_s
10521055
i64.and
10531056
i64.const 1
10541057
i64.shl
@@ -1059,7 +1062,8 @@
10591062
i64.extend_i32_u
10601063
i64.add
10611064
i64.const 52
1062-
i64.const 7
1065+
i32.const 7
1066+
i64.extend_i32_s
10631067
i64.sub
10641068
i64.shl
10651069
local.set $13
@@ -2049,7 +2053,8 @@
20492053
i64.extend_i32_u
20502054
i64.add
20512055
i64.const 52
2052-
i64.const 5
2056+
i32.const 5
2057+
i64.extend_i32_s
20532058
i64.sub
20542059
i64.shl
20552060
i64.add

tests/compiler/call-super.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,8 @@
15361536
drop
15371537
global.get $~lib/rt/itcms/total
15381538
i64.extend_i32_u
1539-
i64.const 200
1539+
i32.const 200
1540+
i64.extend_i32_u
15401541
i64.mul
15411542
i64.const 100
15421543
i64.div_u

tests/compiler/class-implements.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,8 @@
15461546
drop
15471547
global.get $~lib/rt/itcms/total
15481548
i64.extend_i32_u
1549-
i64.const 200
1549+
i32.const 200
1550+
i64.extend_i32_u
15501551
i64.mul
15511552
i64.const 100
15521553
i64.div_u

tests/compiler/class-overloading-cast.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,8 @@
15461546
drop
15471547
global.get $~lib/rt/itcms/total
15481548
i64.extend_i32_u
1549-
i64.const 200
1549+
i32.const 200
1550+
i64.extend_i32_u
15501551
i64.mul
15511552
i64.const 100
15521553
i64.div_u

tests/compiler/class-overloading.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,8 @@
15521552
drop
15531553
global.get $~lib/rt/itcms/total
15541554
i64.extend_i32_u
1555-
i64.const 200
1555+
i32.const 200
1556+
i64.extend_i32_u
15561557
i64.mul
15571558
i64.const 100
15581559
i64.div_u

tests/compiler/class.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,8 @@
16491649
drop
16501650
global.get $~lib/rt/itcms/total
16511651
i64.extend_i32_u
1652-
i64.const 200
1652+
i32.const 200
1653+
i64.extend_i32_u
16531654
i64.mul
16541655
i64.const 100
16551656
i64.div_u

tests/compiler/constructor.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,8 @@
15481548
drop
15491549
global.get $~lib/rt/itcms/total
15501550
i64.extend_i32_u
1551-
i64.const 200
1551+
i32.const 200
1552+
i64.extend_i32_u
15521553
i64.mul
15531554
i64.const 100
15541555
i64.div_u

tests/compiler/do.untouched.wat

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,8 @@
19451945
drop
19461946
global.get $~lib/rt/itcms/total
19471947
i64.extend_i32_u
1948-
i64.const 200
1948+
i32.const 200
1949+
i64.extend_i32_u
19491950
i64.mul
19501951
i64.const 100
19511952
i64.div_u
@@ -2928,7 +2929,8 @@
29282929
end
29292930
global.get $~lib/rt/itcms/total
29302931
i64.extend_i32_u
2931-
i64.const 200
2932+
i32.const 200
2933+
i64.extend_i32_u
29322934
i64.mul
29332935
i64.const 100
29342936
i64.div_u

tests/compiler/empty-exportruntime.untouched.wat

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,8 @@
15421542
drop
15431543
global.get $~lib/rt/itcms/total
15441544
i64.extend_i32_u
1545-
i64.const 200
1545+
i32.const 200
1546+
i64.extend_i32_u
15461547
i64.mul
15471548
i64.const 100
15481549
i64.div_u
@@ -2455,7 +2456,8 @@
24552456
end
24562457
global.get $~lib/rt/itcms/total
24572458
i64.extend_i32_u
2458-
i64.const 200
2459+
i32.const 200
2460+
i64.extend_i32_u
24592461
i64.mul
24602462
i64.const 100
24612463
i64.div_u

tests/compiler/empty-new.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,8 @@
15351535
drop
15361536
global.get $~lib/rt/itcms/total
15371537
i64.extend_i32_u
1538-
i64.const 200
1538+
i32.const 200
1539+
i64.extend_i32_u
15391540
i64.mul
15401541
i64.const 100
15411542
i64.div_u

tests/compiler/exports.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,8 @@
15991599
drop
16001600
global.get $~lib/rt/itcms/total
16011601
i64.extend_i32_u
1602-
i64.const 200
1602+
i32.const 200
1603+
i64.extend_i32_u
16031604
i64.mul
16041605
i64.const 100
16051606
i64.div_u

tests/compiler/exportstar-rereexport.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,8 @@
15801580
drop
15811581
global.get $~lib/rt/itcms/total
15821582
i64.extend_i32_u
1583-
i64.const 200
1583+
i32.const 200
1584+
i64.extend_i32_u
15841585
i64.mul
15851586
i64.const 100
15861587
i64.div_u

tests/compiler/extends-baseaggregate.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,8 @@
15451545
drop
15461546
global.get $~lib/rt/itcms/total
15471547
i64.extend_i32_u
1548-
i64.const 200
1548+
i32.const 200
1549+
i64.extend_i32_u
15491550
i64.mul
15501551
i64.const 100
15511552
i64.div_u

tests/compiler/extends-recursive.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,8 @@
15401540
drop
15411541
global.get $~lib/rt/itcms/total
15421542
i64.extend_i32_u
1543-
i64.const 200
1543+
i32.const 200
1544+
i64.extend_i32_u
15441545
i64.mul
15451546
i64.const 100
15461547
i64.div_u

tests/compiler/field-initialization.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,8 @@
15451545
drop
15461546
global.get $~lib/rt/itcms/total
15471547
i64.extend_i32_u
1548-
i64.const 200
1548+
i32.const 200
1549+
i64.extend_i32_u
15491550
i64.mul
15501551
i64.const 100
15511552
i64.div_u

tests/compiler/field.untouched.wat

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,8 @@
15371537
drop
15381538
global.get $~lib/rt/itcms/total
15391539
i64.extend_i32_u
1540-
i64.const 200
1540+
i32.const 200
1541+
i64.extend_i32_u
15411542
i64.mul
15421543
i64.const 100
15431544
i64.div_u
@@ -3753,7 +3754,8 @@
37533754
end
37543755
global.get $~lib/rt/itcms/total
37553756
i64.extend_i32_u
3756-
i64.const 200
3757+
i32.const 200
3758+
i64.extend_i32_u
37573759
i64.mul
37583760
i64.const 100
37593761
i64.div_u

tests/compiler/for.untouched.wat

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,8 @@
19621962
drop
19631963
global.get $~lib/rt/itcms/total
19641964
i64.extend_i32_u
1965-
i64.const 200
1965+
i32.const 200
1966+
i64.extend_i32_u
19661967
i64.mul
19671968
i64.const 100
19681969
i64.div_u
@@ -2963,7 +2964,8 @@
29632964
end
29642965
global.get $~lib/rt/itcms/total
29652966
i64.extend_i32_u
2966-
i64.const 200
2967+
i32.const 200
2968+
i64.extend_i32_u
29672969
i64.mul
29682970
i64.const 100
29692971
i64.div_u

tests/compiler/function-call.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,8 @@
15701570
drop
15711571
global.get $~lib/rt/itcms/total
15721572
i64.extend_i32_u
1573-
i64.const 200
1573+
i32.const 200
1574+
i64.extend_i32_u
15741575
i64.mul
15751576
i64.const 100
15761577
i64.div_u

tests/compiler/function-expression.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,8 @@
17261726
drop
17271727
global.get $~lib/rt/itcms/total
17281728
i64.extend_i32_u
1729-
i64.const 200
1729+
i32.const 200
1730+
i64.extend_i32_u
17301731
i64.mul
17311732
i64.const 100
17321733
i64.div_u

tests/compiler/getter-call.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,8 @@
15381538
drop
15391539
global.get $~lib/rt/itcms/total
15401540
i64.extend_i32_u
1541-
i64.const 200
1541+
i32.const 200
1542+
i64.extend_i32_u
15421543
i64.mul
15431544
i64.const 100
15441545
i64.div_u

tests/compiler/implicit-getter-setter.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,8 @@
15451545
drop
15461546
global.get $~lib/rt/itcms/total
15471547
i64.extend_i32_u
1548-
i64.const 200
1548+
i32.const 200
1549+
i64.extend_i32_u
15491550
i64.mul
15501551
i64.const 100
15511552
i64.div_u

tests/compiler/infer-array.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,8 @@
15541554
drop
15551555
global.get $~lib/rt/itcms/total
15561556
i64.extend_i32_u
1557-
i64.const 200
1557+
i32.const 200
1558+
i64.extend_i32_u
15581559
i64.mul
15591560
i64.const 100
15601561
i64.div_u

tests/compiler/infer-generic.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,8 @@
16241624
drop
16251625
global.get $~lib/rt/itcms/total
16261626
i64.extend_i32_u
1627-
i64.const 200
1627+
i32.const 200
1628+
i64.extend_i32_u
16281629
i64.mul
16291630
i64.const 100
16301631
i64.div_u

tests/compiler/inlining.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,8 @@
17441744
drop
17451745
global.get $~lib/rt/itcms/total
17461746
i64.extend_i32_u
1747-
i64.const 200
1747+
i32.const 200
1748+
i64.extend_i32_u
17481749
i64.mul
17491750
i64.const 100
17501751
i64.div_u

tests/compiler/instanceof-class.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,8 @@
15381538
drop
15391539
global.get $~lib/rt/itcms/total
15401540
i64.extend_i32_u
1541-
i64.const 200
1541+
i32.const 200
1542+
i64.extend_i32_u
15421543
i64.mul
15431544
i64.const 100
15441545
i64.div_u

tests/compiler/issues/1095.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,8 @@
15381538
drop
15391539
global.get $~lib/rt/itcms/total
15401540
i64.extend_i32_u
1541-
i64.const 200
1541+
i32.const 200
1542+
i64.extend_i32_u
15421543
i64.mul
15431544
i64.const 100
15441545
i64.div_u

tests/compiler/issues/1225.untouched.wat

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,8 @@
15491549
drop
15501550
global.get $~lib/rt/itcms/total
15511551
i64.extend_i32_u
1552-
i64.const 200
1552+
i32.const 200
1553+
i64.extend_i32_u
15531554
i64.mul
15541555
i64.const 100
15551556
i64.div_u
@@ -2408,7 +2409,8 @@
24082409
end
24092410
global.get $~lib/rt/itcms/total
24102411
i64.extend_i32_u
2411-
i64.const 200
2412+
i32.const 200
2413+
i64.extend_i32_u
24122414
i64.mul
24132415
i64.const 100
24142416
i64.div_u

tests/compiler/issues/1699.untouched.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,8 @@
15401540
drop
15411541
global.get $~lib/rt/itcms/total
15421542
i64.extend_i32_u
1543-
i64.const 200
1543+
i32.const 200
1544+
i64.extend_i32_u
15441545
i64.mul
15451546
i64.const 100
15461547
i64.div_u

0 commit comments

Comments
 (0)