Skip to content

fix: Types of small integer constants should always set a current type #2132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3391,14 +3391,8 @@ export class Compiler extends DiagnosticEmitter {
): ExpressionRef {
assert(element.is(CommonFlags.INLINED | CommonFlags.RESOLVED));
var type = element.type;
switch (
!(constraints & (Constraints.CONV_IMPLICIT | Constraints.CONV_EXPLICIT)) &&
type.isIntegerValue &&
contextualType.isIntegerValue &&
type.size < contextualType.size
? (this.currentType = contextualType).kind // essentially precomputes a (sign-)extension
: (this.currentType = type).kind
) {
this.currentType = type;
switch (type.kind) {
case TypeKind.I8:
case TypeKind.I16: {
let shift = type.computeSmallIntegerShift(Type.i32);
Expand Down
15 changes: 10 additions & 5 deletions tests/compiler/binary.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -722,10 +722,12 @@
local.set $11
local.get $11
i64.const 52
i64.const 7
i32.const 7
i64.extend_i32_s
i64.sub
i64.shr_u
i64.const 127
i32.const 127
i64.extend_i32_s
i64.and
i32.wrap_i64
local.set $12
Expand Down Expand Up @@ -1048,7 +1050,8 @@
f64.add
local.set $28
local.get $14
i64.const 127
i32.const 127
i64.extend_i32_s
i64.and
i64.const 1
i64.shl
Expand All @@ -1059,7 +1062,8 @@
i64.extend_i32_u
i64.add
i64.const 52
i64.const 7
i32.const 7
i64.extend_i32_s
i64.sub
i64.shl
local.set $13
Expand Down Expand Up @@ -2049,7 +2053,8 @@
i64.extend_i32_u
i64.add
i64.const 52
i64.const 5
i32.const 5
i64.extend_i32_s
i64.sub
i64.shl
i64.add
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/call-super.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/class-implements.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/class-overloading-cast.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/class-overloading.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/class.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/constructor.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
6 changes: 4 additions & 2 deletions tests/compiler/do.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1945,7 +1945,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down Expand Up @@ -2928,7 +2929,8 @@
end
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
6 changes: 4 additions & 2 deletions tests/compiler/empty-exportruntime.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down Expand Up @@ -2455,7 +2456,8 @@
end
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/empty-new.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/exports.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/exportstar-rereexport.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/extends-baseaggregate.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/extends-recursive.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/field-initialization.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
6 changes: 4 additions & 2 deletions tests/compiler/field.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down Expand Up @@ -3753,7 +3754,8 @@
end
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
6 changes: 4 additions & 2 deletions tests/compiler/for.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down Expand Up @@ -2963,7 +2964,8 @@
end
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/function-call.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/function-expression.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/getter-call.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/implicit-getter-setter.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/infer-array.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/infer-generic.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/inlining.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/instanceof-class.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/issues/1095.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
6 changes: 4 additions & 2 deletions tests/compiler/issues/1225.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down Expand Up @@ -2408,7 +2409,8 @@
end
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/issues/1699.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,8 @@
drop
global.get $~lib/rt/itcms/total
i64.extend_i32_u
i64.const 200
i32.const 200
i64.extend_i32_u
i64.mul
i64.const 100
i64.div_u
Expand Down
Loading