Thread overview |
---|
July 31, 2015 alias overloading strange error | ||||
---|---|---|---|---|
| ||||
//Why expression 'foobar(1);' doesn't work? void foo()(){} void bar(int){} alias foobar = foo; alias foobar = bar; void main(){ .foobar(1); //OK foobar(1); //Error: overload alias 'foo' is not a variable } |
July 31, 2015 Re: alias overloading strange error | ||||
---|---|---|---|---|
| ||||
Posted in reply to vitus | On Friday, 31 July 2015 at 10:56:33 UTC, vitus wrote:
> //Why expression 'foobar(1);' doesn't work?
>
>
> void foo()(){}
> void bar(int){}
>
> alias foobar = foo;
> alias foobar = bar;
>
> void main(){
> .foobar(1); //OK
> foobar(1); //Error: overload alias 'foo' is not a variable
>
> }
foo is a template, while bar is a function. I would have thought the `.foobar(1)` should have failed too... Must be some strange lookup rules I don't know about (or a dmd bug).
`alias foobar = foo!();` should make it work in both cases though.
|
July 31, 2015 Re: alias overloading strange error | ||||
---|---|---|---|---|
| ||||
Posted in reply to vitus | On Friday, 31 July 2015 at 10:56:33 UTC, vitus wrote: > //Why expression 'foobar(1);' doesn't work? > > > void foo()(){} > void bar(int){} > > alias foobar = foo; > alias foobar = bar; > > void main(){ > .foobar(1); //OK > foobar(1); //Error: overload alias 'foo' is not a variable > > } It works when you switch the aliases around: ---- void foo()(){} void bar(int){} alias foobar = bar; alias foobar = foo; void main(){ foobar(1); } ---- Definitely a bug. Please file an issue at <https://issues.dlang.org/>. |
August 01, 2015 Re: alias overloading strange error | ||||
---|---|---|---|---|
| ||||
Posted in reply to anonymous | On Friday, 31 July 2015 at 11:09:39 UTC, anonymous wrote: > Definitely a bug. Please file an issue at <https://issues.dlang.org/>. https://issues.dlang.org/show_bug.cgi?id=14858 |
Copyright © 1999-2021 by the D Language Foundation