Skip to content

A rule for directly indexing/newindexing globals through getfenv() #319

@1Kaetar

Description

@1Kaetar

a filter_global_assignment rule would serve useful in the case that rename_variables changes variable names to already existing global names. I have currently had an issue with the rename_variables rule overriding local variable names to existing global names and causing errors within my script.

It would also be a fair option to ditch this entirely for an extra parameter to also rename globals.

Examples

--unmodified
a = 0;
local b = 1;

print(a);
-- outputs: 0
-- expected output: 0
--rename_variables transform
a = 0;
local a = 1;

print(a);
-- outputs: 1
-- expected output: 0
--filter_global_assignment > rename_variables transform
getfenv().a = 0;
local a = 1;

print(getfenv().a);
-- outputs: 0
-- expected output: 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions