diff options
| -rw-r--r-- | source/slang/check.cpp | 11 | ||||
| -rw-r--r-- | source/slang/syntax.cpp | 9 | ||||
| -rw-r--r-- | tests/bugs/gh-449.slang | 25 | ||||
| -rw-r--r-- | tests/bugs/gh-449.slang.expected | 7 |
4 files changed, 46 insertions, 6 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp index dbd9b37b7..2b7f8f2fc 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -5419,17 +5419,22 @@ namespace Slang // Their arguments must unify SLANG_RELEASE_ASSERT(fstGen->args.Count() == sndGen->args.Count()); UInt argCount = fstGen->args.Count(); + bool okay = true; for (UInt aa = 0; aa < argCount; ++aa) { if (!TryUnifyVals(constraints, fstGen->args[aa], sndGen->args[aa])) - return false; + { + okay = false; + } } // Their "base" specializations must unify if (!TryUnifySubstitutions(constraints, fstGen->outer, sndGen->outer)) - return false; + { + okay = false; + } - return true; + return okay; } bool TryUnifyTypeParam( diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp index 4881f301e..70e230f33 100644 --- a/source/slang/syntax.cpp +++ b/source/slang/syntax.cpp @@ -2011,10 +2011,13 @@ void Type::accept(IValVisitor* visitor, void* extra) String DeclRefBase::toString() const { - StringBuilder sb; - sb << this->getDecl()->getName()->text; + if (!decl) return ""; + + auto name = decl->getName(); + if (!name) return ""; + // TODO: need to print out substitutions too! - return sb.ProduceString(); + return name->text; } RefPtr<ThisTypeSubstitution> getThisTypeSubst(DeclRefBase & declRef, bool insertSubstEntry) diff --git a/tests/bugs/gh-449.slang b/tests/bugs/gh-449.slang new file mode 100644 index 000000000..9ce678b53 --- /dev/null +++ b/tests/bugs/gh-449.slang @@ -0,0 +1,25 @@ +// gh-449.slang +//TEST:SIMPLE: + +// Issue when dealing with binary operations that +// mix scalars with vectors that have a different +// element type. + +struct S { int dummy; }; + +void foo(S s); + +void main() +{ + // This works fine right now. The `uint` gets converted to a + // `float`, and then we do the addition. + float2 a = float2(1, 2); + uint b = 3; + foo(a + b); + + // This used to get confused, with the `f` getting converted + // to a `uint` before the addition. + uint2 u = uint2(1, 2); + float f = 3.0; + foo(u + f); +} diff --git a/tests/bugs/gh-449.slang.expected b/tests/bugs/gh-449.slang.expected new file mode 100644 index 000000000..2bf08bed2 --- /dev/null +++ b/tests/bugs/gh-449.slang.expected @@ -0,0 +1,7 @@ +result code = -1 +standard error = { +tests/bugs/gh-449.slang(18): error 30019: expected an expression of type 'S', got 'vector<float,2>' +tests/bugs/gh-449.slang(24): error 30019: expected an expression of type 'S', got 'vector<float,2>' +} +standard output = { +} |
