Skip to content

Commit a17b68a

Browse files
author
Tim Foley
authored
Produce a better error message on errors in inheritance clauses (shader-slang#828)
If I write: ``` struct Foo : IDoesntExist {} ``` Then currently Slang complains first that `IDoesntExist` is an undefined identifier, then it complains that it expected an interface type in the inheritance clause. The second ("cascading") error isn't really helpful, because of *course* if something isn't defined it isn't an interface. This change detects the case where the type expression is erroneous so that we avoid the cascading error.
1 parent 9b80537 commit a17b68a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

source/slang/check.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -2310,6 +2310,11 @@ namespace Slang
23102310
return;
23112311
}
23122312
}
2313+
else if(base.type.is<ErrorType>())
2314+
{
2315+
// If an error was already produced, don't emit a cascading error.
2316+
return;
2317+
}
23132318

23142319
// If type expression didn't name an interface, we'll emit an error here
23152320
// TODO: deal with the case of an error in the type expression (don't cascade)

0 commit comments

Comments
 (0)