Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
March 28, 2015 [Issue 14353] SDC test0104.d fails under DMD | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14353 Shammah Chancellor <shammah.chancellor@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |shammah.chancellor@gmail.co | |m -- |
March 28, 2015 [Issue 14353] SDC test0104.d fails under DMD | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14353 ag0aep6g@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ag0aep6g@gmail.com --- Comment #1 from ag0aep6g@gmail.com --- I think this is invalid. `t.add` and `s.add` are parentheses-less calls. So the error about T.add not being callable "using argument types ()" is correct. To get a delegate, add '&': struct S { int i; T t; auto add(int a) { t.i = a + i; return &t.add; /* ! */ } } struct T { int i; int add(int a) { return i + a; } } int main() { S s; s.i = s.t.i = 1; auto dg1 = &s.add; /* ! */ auto dg2 = dg1(34); return dg2(7); } -- |
March 28, 2015 [Issue 14353] SDC test0104.d fails under DMD | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14353 --- Comment #2 from Shammah Chancellor <shammah.chancellor@gmail.com> --- Definitely possible. I will file an SDC bug if this turns out to be the case. -- |
March 28, 2015 [Issue 14353] SDC test0104.d fails under DMD | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14353 --- Comment #3 from Shammah Chancellor <shammah.chancellor@gmail.com> --- I'm not so sure this is desirable. What if there add as a ref return. What does &t.foo give then? -- |
March 28, 2015 [Issue 14353] SDC test0104.d fails under DMD | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14353 --- Comment #4 from Ketmar Dark <ketmar@ketmar.no-ip.org> --- i believe that it will be a bug in the D code, as there is no variable to ref. at least it should be a bug. ;-) -- |
March 28, 2015 [Issue 14353] SDC test0104.d fails under DMD | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14353 --- Comment #5 from ag0aep6g@gmail.com --- (In reply to Shammah Chancellor from comment #3) > I'm not so sure this is desirable. What if there add as a ref return. What does &t.foo give then? You mean something like the following? ---- struct T { int i = 42; ref int foo() {return i;} } void main() { T t; auto dg = &t.foo; auto i = &t.foo(); } ---- Here dg is a delegate of the method foo and i is a pointer to the ref-returned field i. The spec says this [1]: "In most places, getter property functions are called immediately. One exceptional case is the address operator." "Even if the given operand is a property function, the address operator returns the address of the property function rather than the address of its return value." Now foo is no @property, but the spec says that "[if] a function call does not take any arguments syntactically, it is callable without parenthesis, like a getter property functions." So it's reasonable that the same rules apply. [1] http://dlang.org/function.html#property-functions -- |
March 29, 2015 [Issue 14353] SDC test0104.d fails under DMD | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14353 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> --- (In reply to ag0aep6g from comment #1) > I think this is invalid. `t.add` and `s.add` are parentheses-less calls. So the error about T.add not being callable "using argument types ()" is correct. To get a delegate, add '&': That's right. When a function symbol identifier without address operator appears in expressions, it will be evaluated to a parenthesis-less function call. Therefore, it's definitely a bug in SDC. -- |
June 10, 2015 [Issue 14353] SDC test0104.d fails under DMD | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14353 Andrei Alexandrescu <andrei@erdani.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |D2 -- |
Copyright © 1999-2021 by the D Language Foundation