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

Optimizer and builtin functions #2

Closed
ozanh opened this issue Nov 30, 2020 · 0 comments
Closed

Optimizer and builtin functions #2

ozanh opened this issue Nov 30, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@ozanh
Copy link
Owner

ozanh commented Nov 30, 2020

uGO allows to shadow builtin symbols, but this causes optimizer, that has no symbol table, to evaluate builtin function calls as if they are not shadowed as shown in the example;

string := func() { /* ... */ }
a := string(1)
println(a)

Result:

Bytecode
Modules:0
Constants:
   0: CompiledFunction
	Params:0 Variadic:false Locals:0
	Instructions:
	0000 RETURN          0
	SourceMap:map[0:0]
   1: "1"|string
Params:0 Variadic:false Locals:2
Instructions:
0000 CONSTANT        0
0003 SETLOCAL        0
0005 CONSTANT        1
0008 SETLOCAL        1
0010 GETBUILTIN      19
0012 GETLOCAL        1
0014 CALL            1    0
0017 POP
0018 RETURN          0

Output:
"1"

"1" is not the expected output. Either disable evaluating builtins or throw a meaningful error.

@ozanh ozanh added the bug Something isn't working label Nov 30, 2020
@ozanh ozanh closed this as completed in 8588e22 Dec 2, 2020
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

No branches or pull requests

1 participant