View Single Post
ainn
New Member
Join Date: Nov 2020
Old 11-26-2020 , 20:01   Re: Enum Structs Available This Holiday Season
Reply With Quote #43

First of all, thanks for the useful feature.

I'm curious, is this a bug or working as intended:

PHP Code:
// This compiles (SourcePawn Compiler 1.10)

enum struct Foo {
    
int a;
    
    
int bar()
    {
        
int b this.a;
        return 
b;
    }
}

public 
void OnPluginStart()
{
    
Foo foo;
    
foo.bar();

But this doesn't work, regardless of the pragma.
PHP Code:
// This doesn't compile:
//     plugin.sp(10) : error 147: new-style declarations are required

#pragma newdecls optional

enum struct Foo {
    
int a;
    
    
int bar()
    {
        new 
this.a// old-style decl
        
return b;
    }
}

public 
void OnPluginStart()
{
    
Foo foo;
    
foo.bar();

While you might wonder why I'd want to do this in the first place, I ran into the issue while using some legacy boilerplate for a newer project. Not a big deal having to rewrite it in newdecls style, but just wondering whether the pragma is actually supposed to allow this.

Last edited by ainn; 11-26-2020 at 20:07.
ainn is offline