diff options
Diffstat (limited to 'tests/bugs/ptr-extension-this-type.slang')
| -rw-r--r-- | tests/bugs/ptr-extension-this-type.slang | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/bugs/ptr-extension-this-type.slang b/tests/bugs/ptr-extension-this-type.slang new file mode 100644 index 000000000..627db5302 --- /dev/null +++ b/tests/bugs/ptr-extension-this-type.slang @@ -0,0 +1,28 @@ +//TEST:INTERPRET(filecheck=CHECK): + +// Test for issue #7656: Compiler segfault with Ptr<T> extension referring to This +// This test ensures that the compiler doesn't segfault when 'This' is used in Ptr<T> extensions + +public interface IThing +{ + int f(This other); +} + +public extension Ptr<int>: IThing +{ + public int f(This other) + { + // Test that 'This' refers to Ptr<int>, not the pointed-to type int + return sizeof(This) - sizeof(Ptr<int>) + 1; + } +} + +void main() +{ + Ptr<int> p; + Ptr<int> other; + int result = p.f(other); + + // CHECK: 1 + printf("%d\n", result); +}
\ No newline at end of file |
