File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -3495,6 +3495,28 @@ export class Compiler extends DiagnosticEmitter {
3495
3495
// not dealing with references from here on
3496
3496
assert ( ! fromType . isReference && ! toType . isReference ) ;
3497
3497
3498
+ // Early return if we have same types
3499
+ if ( toType . kind == fromType . kind ) {
3500
+ this . currentType = toType ;
3501
+ return expr ;
3502
+ }
3503
+
3504
+ // v128 to any / any to v128
3505
+ // except v128 to bool
3506
+ //
3507
+ // NOTE:In case we would have more conversions to and from v128 type it's better
3508
+ // to make these checks more individual and integrate in below flow.
3509
+ if (
3510
+ ! toType . isBooleanValue &&
3511
+ ( toType . isVectorValue || fromType . isVectorValue )
3512
+ ) {
3513
+ this . error (
3514
+ DiagnosticCode . Type_0_is_not_assignable_to_type_1 ,
3515
+ reportNode . range , fromType . toString ( ) , toType . toString ( )
3516
+ ) ;
3517
+ return module . unreachable ( ) ;
3518
+ }
3519
+
3498
3520
if ( ! fromType . isAssignableTo ( toType ) ) {
3499
3521
if ( ! explicit ) {
3500
3522
this . error (
Original file line number Diff line number Diff line change
1
+ {
2
+ "asc_flags" : [
3
+ " --enable" , " simd"
4
+ ],
5
+ "stderr" : [
6
+ " TS2322: Type 'f32' is not assignable to type 'v128'." ,
7
+ " TS2322: Type 'i32' is not assignable to type 'v128'." ,
8
+ " EOF"
9
+ ]
10
+ }
Original file line number Diff line number Diff line change
1
+ // f32
2
+ {
3
+ let a = f32x4 . splat ( 0 ) ;
4
+ let b : f32 = 0 ;
5
+ v128 . add < f32 > ( a , b ) ;
6
+ }
7
+
8
+ // i32
9
+ {
10
+ let a : i32 = 0 ;
11
+ let b = i32x4 . splat ( 0 ) ;
12
+ v128 . sub < i32 > ( a , b ) ;
13
+ }
14
+
15
+ ERROR ( "EOF" ) ;
You can’t perform that action at this time.
0 commit comments