pawn-lang / compiler

Pawn compiler for SA-MP with bug fixes and new features - runs on Windows, Linux, macOS
Other
301 stars 71 forks source link

`const` can be specified for a function argument more than once #729

Open Daniel-Cortez opened 7 months ago

Daniel-Cortez commented 7 months ago

Issue description:

While working on an implementation of named-only function arguments (#719), I found an oversight in function declargs(). https://github.com/pawn-lang/compiler/blob/81b4a0243de40ff7bb38520b33054066e998cdc9/source/compiler/sc1.c#L4278-L4282 There's no check if const was already specified, although handlers for other specifiers (&, Tag:, ...) have this kind of check. As a result, the user can specify const any number of times

Func(const const const const arg) {}

and the compiler would think this is okay, although it clearly isn't.

Minimal complete verifiable example (MCVE):

See above.

Workspace Information: