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

Function call parsed as a Type conversion #53

Closed
aryx opened this issue Oct 5, 2021 · 4 comments · Fixed by #126
Closed

Function call parsed as a Type conversion #53

aryx opened this issue Oct 5, 2021 · 4 comments · Fixed by #126

Comments

@aryx
Copy link
Contributor

aryx commented Oct 5, 2021

From semgrep/semgrep#3993

this program:

_ := os.GetEnv("Test")

without the ending newline is parsed as a type conversion instead of a regular function call.

@adonovan
Copy link
Contributor

adonovan commented Mar 22, 2022

Perhaps it is a type conversion: you can't tell without seeing whether package os defines type GetEnv string or func GetEnv(string) string, and the parser is not privy to that information.

@aryx
Copy link
Contributor Author

aryx commented Dec 22, 2022

Still it's weird that a newline has an impact on how this thing is parsed.

@aryx
Copy link
Contributor Author

aryx commented Dec 22, 2022

And in any case, because tree-sitter does not have the information, it should parse it as a function call, not a cast.
It should return a Cast node when we know for sure the thing is a type, as in _ := int(3)

@amaanq amaanq mentioned this issue Jul 26, 2023
@dominikh
Copy link

@aryx

It should return a Cast node when we know for sure the thing is a type, as in _ := int(3)

Do note that even in that case, int could just as easily refer to a function that is shadowing the predeclared type int.

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

Successfully merging a pull request may close this issue.

3 participants