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

[BUG] [ZScript] "Invalid Scope for Function Pointer" in struct #2814

Open
1 task done
Player701 opened this issue Nov 14, 2024 · 1 comment
Open
1 task done

[BUG] [ZScript] "Invalid Scope for Function Pointer" in struct #2814

Player701 opened this issue Nov 14, 2024 · 1 comment
Labels

Comments

@Player701
Copy link
Contributor

GZDoom version

4.13.2 and 4.14pre-76-gccd38afbc

Which game are you running with GZDoom?

Doom 2

What Operating System are you using?

Windows 11

Please describe your specific OS version

N/A

Relevant hardware info

N/A

Have you checked that no other similar issue already exists?

  • I have searched and not found similar issues.

A clear and concise description of what the bug is.

This script works:

version "4.13"

class Test
{
    Function<play void()> f;
}

but change class to struct, and you get:

zscript.txt:zscript.txt, line 5: Invalid Scope for Function Pointer

Only clearscope seems to work; neither play nor ui does. Changing the scope of the struct itself to play or ui does not appear to have any effect either.

However, it is possible to work around this by declaring the type as Function<void>, but then a cast to the proper type will be necessary in order to call the function declared this way. Which makes me think this is likely a bug in the compiler and not some kind of fundamental limitation of the ZScript architecture.

Steps to reproduce the behaviour.

  1. Load the Zscript file provided in the description
  2. Observe that there is no error
  3. Change class to struct in the script code and try again
  4. Observe the error: "Invalid Scope for Function Pointer"

Your configuration

N/A

Provide a Log

N/A

@Player701 Player701 added the bug label Nov 14, 2024
@RicardoLuis0
Copy link
Collaborator

hmm, that shouldn't be triggering at all since it's defined as play scope, is the parser doing something funky to struct members?
https://github.com/ZDoom/gzdoom/blob/master/src/common/scripting/frontend/zcc_compile.cpp#L2072

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants