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

native operators overload can return arrays #685

Open
YashasSamaga opened this issue Oct 8, 2021 · 2 comments · May be fixed by #686
Open

native operators overload can return arrays #685

YashasSamaga opened this issue Oct 8, 2021 · 2 comments · May be fixed by #686

Comments

@YashasSamaga
Copy link
Member

Issue description:

Native operator overloads can specify an array return type. They should have the same semantics as non-native operator overloads. The compiler fails to diagnose it.

Minimal complete verifiable example (MCVE):

This compiles:

native Float:[10]operator+(Float:a, Float:b) = 0;
main () { }

This doesn't:

Float:[10]operator-(Float:a, Float:b) { }
main () { }

Workspace Information:

  • Compiler version: 3.10.10
  • Command line arguments provided (or sampctl version): pawncc main.pwn
  • Operating System: Ubuntu 20.04
@Daniel-Cortez
Copy link
Contributor

Daniel-Cortez commented Oct 8, 2021

This doesn't:

Float:[10]operator-(Float:a, Float:b) { }
main () { }

This is because return array sizes are only valid in new-style function declarations that start either from keyword forward, or native. For example, this code

forward Float:[10]operator-(Float:a, Float:b);
main(){ }

would compile as well.

I think the real problem here is that operators aren't actually supposed to return arrays at all, and the compiler doesn't diagnose this. Fixing this shouldn't be hard.

@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had recent activity.

@stale stale bot added the state: stale label Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants