Skip to content

Crash when using this in a static fn #9574

@h3r2tic

Description

@h3r2tic

Issue Description

When you explicitly use this in a static member function of a struct, Slang crashes.

Reproducer Code

struct Foo {
    int a;

    static int func() {
        return this.a;
    }
}

Expected Behavior

A compiler error is reported. Note that this is already the case if this. is implicit instead.

Actual Behavior

Segfault:

#0  0x00007fb924751148 _ZN5Slang15PeepholeContext11processInstEPNS_6IRInstE (libslang-compiler.so.0.2025.24.3 + 0x751148)
#1  0x00007fb92475377f _ZN5Slang15PeepholeContext11processFuncEPNS_6IRInstE (libslang-compiler.so.0.2025.24.3 + 0x75377f)
#2  0x00007fb92474ce8f _ZN5Slang16peepholeOptimizeEPNS_13TargetProgramEPNS_8IRModuleENS_27PeepholeOptimizationOptionsE (libslang-compiler.so.0.2025.24.3 + 0x74ce8f)
#3  0x00007fb9248b8f76 _ZN5Slang28generateIRForTranslationUnitEPNS_10ASTBuilderEPNS_22TranslationUnitRequestE (libslang-compiler.so.0.2025.24.3 + 0x8b8f76)
#4  0x00007fb924446211 _ZN5Slang22FrontEndCompileRequest10generateIREv (libslang-compiler.so.0.2025.24.3 + 0x446211)
#5  0x00007fb92444c86f _ZN5Slang22FrontEndCompileRequest19executeActionsInnerEv (libslang-compiler.so.0.2025.24.3 + 0x44c86f)
#6  0x00007fb92455de7a _ZN5Slang22EndToEndCompileRequest19executeActionsInnerEv (libslang-compiler.so.0.2025.24.3 + 0x55de7a)
#7  0x00007fb92455ef3d _ZN5Slang22EndToEndCompileRequest14executeActionsEv (libslang-compiler.so.0.2025.24.3 + 0x55ef3d)
#8  0x00007fb92455f066 _ZN5Slang22EndToEndCompileRequest7compileEv (libslang-compiler.so.0.2025.24.3 + 0x55f066)

Environment

  • Slang Version: 2025.21.2, 2025.24.3
  • OS: Linux 6.18.2-arch2-1 x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions