<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/language-feature/error-handling, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2025-05-23T19:27:37+00:00</updated>
<entry>
<title>Implement throw &amp; catch statements (#6916)</title>
<updated>2025-05-23T19:27:37+00:00</updated>
<author>
<name>Julius Ikkala</name>
<email>julius.ikkala@gmail.com</email>
</author>
<published>2025-05-23T19:27:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=57c3f938221c427b78da7087f8a832ba4a271a7c'/>
<id>urn:sha1:57c3f938221c427b78da7087f8a832ba4a271a7c</id>
<content type='text'>
* Implement throw statement

It already existed in the IR, so only parsing, checking and lowering was
missing.

* Initial catch implementation

Likely very broken.

* Error out when catch() isn't last in scope

* Prevent accessing variables from scope preceding catch

As those may actually not be available at that point.

* Add IError and use it in Result type lowering

* Add diagnostic tests

* Allow caught throws in non-throw functions

* Fix catch propagating between functions &amp; SPIR-V merge issue

* Add test for non-trivial error types

* Fix MSVC build

* Fix invalid value type from Result lowering

* Also lower error handling in templates

* Lower result types only after specialization

* Attempt to disambiguate error enums by witness table

* Revert matching by witness, types should be distinct too

* Don't assert valueField when getting Result's error value

It may not exist if the function returns void, but getting the error
value is still legitimate.

* Update tests for new error numbers &amp; get rid of expected.txt

* Change catch lowering to resemble breaking a loop

... To make SPIR-V happy.

* Fix dead catch blocks and invalid cached dominator tree

* More SPIR-V adjustment

* Lower catch as two nested loops

* Add defer interaction test and revert broken defer changes

* Fix enum type when throwing literals

* Cleanup and bikeshedding

* Document error handling mechanism

* Fix table of contents

* Use boolean tag in Result&lt;T, E&gt;

* Use anyValue storage for Result&lt;T,E&gt;

* Remove IError

* Fix formatting

* Eradicate success values from docs and tests

* Use parseModernParamDecl for catch parameter

* Implement do-catch syntax

* Implement catch-all

* Fix formatting

* Fix marshalling native calls that throw

---------

Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;</content>
</entry>
</feed>
