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

Declaring variables causes a warning when macro is used. #190

Open
softwareantics opened this issue Feb 19, 2023 · 3 comments
Open

Declaring variables causes a warning when macro is used. #190

softwareantics opened this issue Feb 19, 2023 · 3 comments

Comments

@softwareantics
Copy link

Current Behavior

Declaring a variable causes a warning to be shown if a macro is defined in place of self. This only occurs for constructors and events (ie, the create event). Note also that an error is shown for structs.

Expected Behavior

Regardless of the macro, this really shouldn't produce a warning.

Failure Information (for bugs)

image

Steps to Reproduce

  1. Declare a macro to use in place of self
#macro this self
  1. Create a new script or object, copy and paste the following:
function test_struct() constructor
{
    this.test = "";
}
  1. Note the warning that is displayed.

image

image

Context

  • Operating System: Windows 10 Home
  • Hardware: Intel i7-10710U @ 1.1GHz, 32GB RAM
  • Toolchain: GMS Runtime 2023.200.0.298, GMEdit Dec 24, 2022
@softwareantics
Copy link
Author

softwareantics commented Feb 19, 2023

I don't know if there is a temporary solution to this that will still allow me to keep my styling. Is there a comment or something I can use to disable the warnings in a particular file? Much like feather can be disabled. If not, perhaps I should remove my macro.

@YellowAfterlife
Copy link
Owner

YellowAfterlife commented Feb 19, 2023

Indexer (which fills out information for types) isn't aware of macros and is pretty quick & stupid in general.

Changing this requires making the indexer multi-pass (store all code, process all macros, then run through the code again, now while expanding macros), which is a huge amount of work and probably won't happen too soon.

You might hardcode a workaround by modifying this line in app.js

if(c == 102 && dp >= 3 && q.source.substr((dp - 3),4) == "self" && (dp == 3 || !tools_CharCode.isIdent1_ni(q.source.charCodeAt(dp - 4)))) {
				isDotSelf = true;
			}

to be

if(c == 102 && dp >= 3 && (q.source.substr((dp - 3),4) == "self" || q.source.substr((dp - 3),4) == "this") && (dp == 3 || !tools_CharCode.isIdent1_ni(q.source.charCodeAt(dp - 4)))) {
				isDotSelf = true;
			}

@softwareantics
Copy link
Author

Okay, if you see this as too much effort for something that likely wouldn't be an issue for most people I don't mind closing :)

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

No branches or pull requests

2 participants