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

Unassigned variables used with IsSet still generate a warning #334

Closed
Lexikos opened this issue Jun 10, 2023 · 2 comments
Closed

Unassigned variables used with IsSet still generate a warning #334

Lexikos opened this issue Jun 10, 2023 · 2 comments

Comments

@Lexikos
Copy link

Lexikos commented Jun 10, 2023

MsgBox IsSet(nope)

Variable 'nope' appears to never be assigned a value

One use of IsSet is to check for the presence of a class, function or other variable in a script which may or may not define it. For instance, a file may be used both standalone and as an #include.

  • In the former case, the variable is not defined. There is no warning from AutoHotkey, and getting a warning from the editor is distracting.
  • In the latter case, the main script can define a variable which affects the behaviour of the #include. An assignment cannot be included to suppress the warning, because the variable may be defined by a class or function. If the overall script defines a class or function, the interpreter would flag the assignment as an error.

For #Warn VarUnset, IsSet(nope) provides a way to suppress warnings about a specific global variable while still allowing the use case described above.

IsSet(nope) should not cause a warning even if the variable is not assigned. It should prevent other references to the variable from causing this warning.

@thqby
Copy link
Owner

thqby commented Jun 11, 2023

Yes, this has not yet been implemented. I don't know how to identify this situation yet. IsSet(a?b:c)

@Lexikos
Copy link
Author

Lexikos commented Jun 11, 2023

Identify it for what purpose/in what way?

AutoHotkey doesn't support that. IsSet's parameter expression should be only a plain variable reference or dynamic reference, nothing more complex.

thqby added a commit that referenced this issue Jun 18, 2023
@thqby thqby closed this as completed Jun 19, 2023
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

2 participants