Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sizeof enum struct returns 0 within 'this' context #559

Closed
Adrianilloo opened this issue Apr 12, 2021 · 2 comments
Closed

sizeof enum struct returns 0 within 'this' context #559

Adrianilloo opened this issue Apr 12, 2021 · 2 comments
Labels
bug compiler Problems with the compiler parsing source code.

Comments

@Adrianilloo
Copy link

I found out that calling sizeof for any enum struct within a member function of that enum struct always returns 0.

enum struct STest
{
   int mSample;

    int GetSize()
    {
        return sizeof(STest);
    }
}

public void OnPluginStart()
{
    STest test;
    test.GetSize(); // 0
}

SourcePawn Compiler 1.10.0.6502

Is this accepted?

@asherkin asherkin transferred this issue from alliedmodders/sourcemod Apr 12, 2021
@asherkin
Copy link
Member

Enum structs / methodmaps don't currently "exist" until they're fully parsed, so this is the expected behaviour, but not great behaviour.

See also: #230

@asherkin asherkin added bug compiler Problems with the compiler parsing source code. labels Apr 12, 2021
dvander added a commit that referenced this issue Jul 1, 2021
This error will go away if we can remove the two-pass parsing scheme.

Bug: #559
Test: new compile-only test
dvander added a commit that referenced this issue Jul 1, 2021
This error will go away if we can remove the two-pass parsing scheme.

Bug: #559
Test: new compile-only test
@dvander
Copy link
Member

dvander commented Jul 1, 2021

Thanks, this has been fixed on master.

@dvander dvander closed this as completed Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug compiler Problems with the compiler parsing source code.
Projects
None yet
Development

No branches or pull requests

3 participants