yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Jay KwakReplace the word stdlib or standard-library with core-module for source code (#5415)b7a619b45

master
1.2 KiB41 linesraw
1// extension-lifetime.slang
2
3// This test is a regresion test for a bug where `extension`
4// declarations are incorrectly being cached on the declarations
5// they extend, so that an extension of a core module type (like `float`)
6// ends up attaching a declaration from one compile request to that
7// type, and then later compile requests that use the core module type
8// try to look up through that extension even though (1) that
9// shouldn't make sense semantically, and (2) that extension will
10// have been deallocated when its parent compile request was
11// destroyed.
12//
13// This test relies on the fact that our test runner uses a single
14// slang compilation session (which loads the core module code) across
15// multiple compilation tests. We can thus make this file contain
16// two identical tests, with the knowledge that the second one
17// will lead to the bad/crashing behavior if the first one ran
18// and did a Bad Thing.
19
20//TEST:SIMPLE:
21//TEST:SIMPLE:
22
23interface IThing
24{
25	float getThing();
26}
27
28extension float : IThing
29{
30	float getThing() { return this; }
31}
32
33float getThing<T : IThing>(T value)
34{
35	return value.getThing();
36}
37
38float test( float value )
39{
40	return getThing(value);
41}