<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/language-feature/struct-field-initializers/struct-field-initializer-extension-inheritance.slang, 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-06-12T14:57:42+00:00</updated>
<entry>
<title>Diagnose on use of struct inheritance. (#7419)</title>
<updated>2025-06-12T14:57:42+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2025-06-12T14:57:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=4ae6e9d8b7790d827ca9edd729ad94f38a0c73de'/>
<id>urn:sha1:4ae6e9d8b7790d827ca9edd729ad94f38a0c73de</id>
<content type='text'>
* Diagnose on use of struct inheritance.

* fix test.

* Fix tests.

* fix.

---------

Co-authored-by: ArielG-NV &lt;159081215+ArielG-NV@users.noreply.github.com&gt;</content>
</entry>
<entry>
<title>Init expressions for struct fields support, #3738 (#3907)</title>
<updated>2024-04-16T17:06:23+00:00</updated>
<author>
<name>ArielG-NV</name>
<email>159081215+ArielG-NV@users.noreply.github.com</email>
</author>
<published>2024-04-16T17:06:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=d5d39dda2ec02c1dd21ba34a89f74b27092efcdd'/>
<id>urn:sha1:d5d39dda2ec02c1dd21ba34a89f74b27092efcdd</id>
<content type='text'>
* Init expressions for struct members

Following commit handles init expressions of struct's.

The general implementation follows C++ init expression rules for classes &amp; inherited classes.

The logic was implemented after type resolution (`SemanticsDeclAttributesVisitor`):
1. Create a default constructor if missing.
2. Check all member variables (`this` and `super`) for if a member has an init expression, continue to *3* if found.
3. For each constructor, insert a member variable's init expression at the beginning of a constructor. This is to follow how C++ does construction of objects.

Some important notes about implementation:
* We must handle the scenario that there is inheritance. To handle the inheritance information processing `findLevelsOfInheritance` was created.
* If a user manually sets overload rank's of constructor expression's we have no way to assume new default constructor overload ranks.

* address feedback

- moved all scope bound variables into if statment initializers
- added indent
- changed logic for overloadRank to be centered around positive numbers rather than negative

* Inheritance fixes universally &amp; for struct field init

1. reimplemented struct field logic
2. implemented inheritance through calling a "super-&gt;init()" inisde a constructor for each "this".
3. implemented support for multi level inheritance (4+) and accessing members without a crash.

* add a way to ignore Forward declared constructors.

* a test and fix for a falcor failiure

the following case was not handled: creating an default Ctor due to a non L-Value struct field. Having an empty Ctor causes a warning.

* remove texture/sampler from test since it will break glsl

* get inheritance info using existing lookup logic

modified Facet lookups to store relative depth rather than arbitrary ::Self or' ::Direct for inheritance (which was 'wong' since depth 2 is not Direct, but was considered a Direct inheritance)

* cleanup unused

* cleanup unused functions and whitespace

* fix compile warning

* clean up, reorder, addressed language server fail

changed logic to safeguard bad code --&gt; no longer breaks language server if code is incomplete.

remove the "semi-ordering" logic because caused a crash (and this code does nothing functionally, just thought it would be nice to add if '0 cost').

Remove rank setting for constructors, in place use an addition to the overload system: "this" expressions have calling priority over "super" expressions.
* undo all inheritance depth checks &amp; code added to the inheritance checking algorithm

Reorder default ctor creation and auto-generation of constructor body.

* Handle same struct types during overload resolution

Changed overload resolution logic to properly handle same struct types; added test to check for multi-param same type function overload.

* remove unused ast object

Used unused object in an incorrect way. This caused the compiler to not flag a warning.

* extension support for default constructors

specialization is not supported with default constructors yet.

* fix bugs

Fix bug in override/overload logic with type comparisons.

used wrong type for ctor list construction

Specialization has not been added yet

* disallow default ctor inside extension

* adjust comment, add new tests

* add explicit types to invoke, use faster default ctor lookup.

* adjust syntax &amp; naming as recomended</content>
</entry>
</feed>
