-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
new gensym handling #11985
new gensym handling #11985
Conversation
Araq
commented
Aug 20, 2019
- will fix many template bugs, eventually.
expectArg(conf, switch, arg, pass, info) | ||
case arg | ||
of "0.19": | ||
conf.globalOptions.incl optNimV019 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is optNimV019
related to nimv019
in config/nim.cfg? as i understand this only affects gensym handling, so maybe it should be in the flag name, eg --genSymVersion
, as there could be other transition flags that should be settable independently; eg if in future you'll need a transition between 1.0 and 1.1 that's totally unrelated to gensym handling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are moving over to "trunk based" development, that's why. These transition switches will be collected under useVersion
.
I thought this PR would fix following bugs but apparently it doesn't, and maybe it can't as there's inherent ambiguity: type Foo = object
b: int
proc bar(b = 12) = discard
template fun(b): untyped =
var x: Foo
# each line here would give an error
var x0 = Foo(b: 3)
bar(b=32)
x.b = 5
echo x.b
template fun2(b2): untyped =
var x = Foo(b: 3)
x.b = 5
echo x.b
echo b2
proc main()=
fun2(14) # ok
fun(14) # Error: identifier expected, but found '14'
main()
IMO we should reopen #8899, it's a fool proof solution: template fun(b): untyped =
var x: Foo
var x0 = Foo(`b`: 3)
bar(`b`=32)
x.`b` = 5
x.b = 15 # this one actually means: substitute (eg if user passes an identifier as b, it will work as intended)
echo x.`b` since there's no need to quote valid identifiers (such as template arguments), there's no loss of generality. template baz(field) =
field(32)
baz(`x=`) # will call `x=`(32)
baz(bar) # will call bar(32) |