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

Function gets called when checking if a var with same name is defined #3116

Open
numberlesstim opened this issue Aug 9, 2024 · 2 comments
Open

Comments

@numberlesstim
Copy link

function foo {print 1.}
print defined(foo@).
print defined(foo).

results in the function being called by the last line:
Output:

true
1
false

Expected output:

true
false
@nuggreat
Copy link

nuggreat commented Aug 9, 2024

Using a function with defined is undefined behavior so anything is the expected and correct result. Though for your case assuming it wasn't undefined and you could use defined to check for a function the expected return for me would have been

true
true

this is because functions defined in the same file that they are called are treated as locks which is likely why print defined(foo) ends up calling the function the function.

@JonnyOThan
Copy link
Contributor

Programming language designed by kerbals.

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

No branches or pull requests

3 participants