-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
cgen error for using a default := p or { T{} }
construct in a generic function
#22163
Comments
Note that a very similar program works fine: pub fn f[T](defaults ?T) {
the_default := defaults or { T{} }
dump(the_default)
}
f(123) |
Note also that Perhaps it is just a matter of escaping it, in yet another place? |
C name collision. Yet another case where all V variables should've been named |
We were typing at the same time, you were just faster. :-) |
@JalonSolov my goal has been to generate clean readable code. Like it was written by a human. Every variable starting with |
The reserved C keywords are a limited set, and can be handled. However, in C programs, there can be global symbols, like function names and variable names, and that set is unlimited. We allow Due to that, the V names (that are also user controlled), can still clash with the global names from the C headers, that a V program includes. The potential for conflicts for variables is minimized, because C allows shadowing of global names with ones from a local scope, and V mostly ensures that it always declares and initializes its own variables. |
V doctor:
What did you do?
./v -g -o vdbg cmd/v && ./vdbg a.v
What did you expect to see?
a compiled program
What did you see instead?
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: