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

New compiler: Fix bug where naming a parameter like its function caused a crash #2667

Open
wants to merge 1 commit into
base: ags4
Choose a base branch
from

Conversation

fernewelten
Copy link
Contributor

Fixes #2647.

Parameters act as variables within the function for which they are defined. This leads to trouble inside the compiler when a parameter is named like its own function. Added code that forbids this.

Typical code:

function foo(int foo, int x) 
{}

I took this as an opportunity to streamline the function defining code in general.

Fix bug where naming a parameter like its function leads to a crash
@ivan-mogilko
Copy link
Contributor

ivan-mogilko commented Jan 25, 2025

I can confirm that this fixes the aforementioned crash. But I'm actually not certain if it is correct to disable parameters of same name, because that does not prevent from using this function outside of function, and then local variables of same name are allowed, so this makes things not consistent.

EDIT: both C# and C++ appear to have no problem with either function parameter or local var of the same name as a function.
To clarify, I don't care about being able to name parameters as a function, but my concern is about parameters and local variables treated consistently here, as these are practically same thing from the function's perspective (I think).

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

Successfully merging this pull request may close these issues.

2 participants