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

Inconsistent variable names on instructions with multiple return values #20

Closed
JeanJPNM opened this issue Mar 21, 2022 · 6 comments · Fixed by #21
Closed

Inconsistent variable names on instructions with multiple return values #20

JeanJPNM opened this issue Mar 21, 2022 · 6 comments · Fixed by #21
Labels
bug Something isn't working

Comments

@JeanJPNM
Copy link
Collaborator

Usually assigned variables have their positions in the source file as names. However, that is not the case for variables that are outputted by commands with multiple return values like unitLocate and unitControl (this one in a specific function overload).

Demonstration

Passing the following input to the compiler results in the following output:

const [found, x, y, building] = unitLocate("building", "core", true);

print(found, x, y, building);
ulocate building core 1 @copper t1 t2 t0 t3
print t0
print t1
print t2
print t3
end

While the expected output is:

ulocate building core 1 @copper 1:14 1:17 1:7 1:20
print 1:7
print 1:14
print 1:17
print 1:20
end

I'm sure this has to do with how the macros for those instructions return ObjectValues.
One possible solution would be to add a sort "hook" that gets called when an IValue gets put into a scope with a name. That way certain types of values can rename their internal name to fit that of the scope variable holding them.

@JeanJPNM JeanJPNM added the bug Something isn't working label Mar 21, 2022
@weisrc
Copy link
Collaborator

weisrc commented Mar 21, 2022

I think it can be fixed in the handler VariableDeclaration ArrayPattern. Temp value extends Store value, thus we can add a name to it.

@weisrc
Copy link
Collaborator

weisrc commented Mar 21, 2022

Should I fix it? Or you will include it along with #19 ?

@JeanJPNM
Copy link
Collaborator Author

I will include it with #19

@weisrc
Copy link
Collaborator

weisrc commented Mar 21, 2022

Cool!

@weisrc weisrc closed this as completed Mar 21, 2022
@JeanJPNM
Copy link
Collaborator Author

Better keep it open until it's actually fixed.

@weisrc
Copy link
Collaborator

weisrc commented Mar 21, 2022

Right right right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants