File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -3524,6 +3524,56 @@ class Typer {
3524
3524
}
3525
3525
3526
3526
types.set(node, typeRight)
3527
+
3528
+ // TODO More of them
3529
+ let mathTokens [Token] = [
3530
+ Token.BitwiseXor,
3531
+ Token.BitwiseOr,
3532
+ Token.BitwiseAnd
3533
+ ]
3534
+
3535
+ if mathTokens.includes(op) {
3536
+ // TODO could be optimized to ArrayByValue here
3537
+ // or just allocate a normal class on stack
3538
+ // cause values are possibly primitives?
3539
+ let integers = [
3540
+ typeInt,
3541
+ // TODO big int etc
3542
+
3543
+ typeUInt64,
3544
+ typeUInt32,
3545
+ typeUInt16,
3546
+ typeUInt8,
3547
+
3548
+ typeInt64,
3549
+ typeInt32,
3550
+ typeInt16,
3551
+ typeInt8
3552
+ ]
3553
+
3554
+ if not integers.includes(typeLeft) or not integers.includes(typeRight) {
3555
+ let tokenString = Token.stringify(op)
3556
+
3557
+ let leftString = switch a {
3558
+ case Null:
3559
+ 'null'
3560
+ case _:
3561
+ Type.stringify(typeA)
3562
+ }
3563
+
3564
+ let rightString = switch b {
3565
+ case Null:
3566
+ 'null'
3567
+ case _:
3568
+ Type.stringify(typeB)
3569
+ }
3570
+
3571
+ fail(
3572
+ 'Operator `a \(tokenString) b` requires `a` and `b` of integer types, but got `\(leftString)` and `\(rightString)`',
3573
+ b
3574
+ )
3575
+ }
3576
+ }
3527
3577
}
3528
3578
3529
3579
// `op e` or `e op`
You can’t perform that action at this time.
0 commit comments