summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-stdlib.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2020-08-04 10:43:05 -0700
committerGitHub <noreply@github.com>2020-08-04 10:43:05 -0700
commit00b1fe044840e7818c6c9bcd4c42d4baafd5b78a (patch)
treec7c3f6b4ae1805cf16ebe47db270166a8978a318 /source/slang/slang-stdlib.cpp
parent79ba9279becf480c9d92bb2faaede0e241f0b029 (diff)
Fix stdlib declarations of bit-shift ops (#1471)
The declarations of the left- and right-shift operations in the Slang standard library were set up identically to the declarations of operator binary (and compound binary) operations. A consequence of this choice was that both operands to a shift were expected to have the same type, which can lead to a confusing result. If the user wrote a shift of the form `int >> uint`, then the ordinary promotion rules for Slang would decide to perform the operation on `uint` value, so it would change to `uint(int) >> uint` and perform an unsigned shift, which isn't what the user would expect. The fix implemented here is to make the shift operations be declared separately from the other binary operations, with *two* generic type parameters instead of one: distinct parameters for the left-hand-side and right-hand side types. Each parameter is only constrained to be a built-in integer type.
Diffstat (limited to 'source/slang/slang-stdlib.cpp')
-rw-r--r--source/slang/slang-stdlib.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp
index a310ba748..e0727f19a 100644
--- a/source/slang/slang-stdlib.cpp
+++ b/source/slang/slang-stdlib.cpp
@@ -208,8 +208,6 @@ namespace Slang
{ kIROp_BitAnd, "&", "__BuiltinLogicalType", LOGICAL_MASK },
{ kIROp_BitOr, "|", "__BuiltinLogicalType", LOGICAL_MASK },
{ kIROp_BitXor, "^", "__BuiltinLogicalType", LOGICAL_MASK },
- { kIROp_Lsh, "<<", "__BuiltinIntegerType", INT_MASK },
- { kIROp_Rsh, ">>", "__BuiltinIntegerType", INT_MASK },
{ kIROp_Eql, "==", "__BuiltinType", ANY_MASK | BOOL_RESULT },
{ kIROp_Neq, "!=", "__BuiltinType", ANY_MASK | BOOL_RESULT },
{ kIROp_Greater, ">", "__BuiltinArithmeticType", ARITHMETIC_MASK | BOOL_RESULT },