[Issue 2029] Typesafe variadic functions don't work in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=2029 Walter Bright bugzi...@digitalmars.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution||FIXED --- Comment #14 from Walter Bright bugzi...@digitalmars.com 2009-12-31 11:11:17 PST --- Fixed dmd 1.054 and 2.038 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 2029] Typesafe variadic functions don't work in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=2029 --- Comment #12 from Walter Bright bugzi...@digitalmars.com 2009-12-29 03:08:36 PST --- (In reply to comment #11) Changeset 318 Wrong changeset, oops! 318 is for bugzilla 282 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 2029] Typesafe variadic functions don't work in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=2029 Walter Bright bugzi...@digitalmars.com changed: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #11 from Walter Bright bugzi...@digitalmars.com 2009-12-29 03:04:14 PST --- Changeset 318 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 2029] Typesafe variadic functions don't work in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=2029 Leandro Lucarella llu...@gmail.com changed: What|Removed |Added CC||llu...@gmail.com --- Comment #13 from Leandro Lucarella llu...@gmail.com 2009-12-29 08:47:27 PST --- http://www.dsource.org/projects/dmd/changeset/314 http://www.dsource.org/projects/dmd/changeset/315 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 2029] Typesafe variadic functions don't work in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=2029 --- Comment #9 from Don clugd...@yahoo.com.au 2009-12-23 01:34:48 PST --- The solution is much, much simpler. The problem is that CTFE doesn't support casting array literals to their base type, even though it's a no-op! constfold.c, inside Expression *Cast(Type *type, Type *to, Expression *e1), line 1095: /* Allow casting from one string type to another */ if (e1-op == TOKstring) { if (tb-ty == Tarray typeb-ty == Tarray tb-nextOf()-size() == typeb-nextOf()-size()) { return expType(to, e1); } } +if (e1-op == TOKarrayliteral typeb == tb) +return e1; if (e1-isConst() != 1) return EXP_CANT_INTERPRET; And then in interpret.c, we can remove the error message (line 116): TypeFunction *tf = (TypeFunction *)tb; Type *tret = tf-next-toBasetype(); -if (tf-varargs) -{cantInterpret = 1; -error(Variadic functions are not yet implemented in CTFE); -return NULL; -} // Ensure there are no lazy parameters if (tf-parameters) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 2029] Typesafe variadic functions don't work in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=2029 --- Comment #8 from Don clugd...@yahoo.com.au 2009-11-25 21:23:48 PST --- Thanks, this is helpful. The problem is, that this isn't an isolated bug: the struct constructor bug has the same root cause. I think we need to fix both of them at once. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 2029] Typesafe variadic functions don't work in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=2029 --- Comment #4 from Tomas Lindquist Olsen to...@famolsen.dk 2009-11-18 03:40:17 PST --- Created an attachment (id=501) draft patch for fixing typesafe variadic and ctfe -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 2029] Typesafe variadic functions don't work in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=2029 --- Comment #6 from Tomas Lindquist Olsen to...@famolsen.dk 2009-11-18 03:48:50 PST --- I forgot to mention, the patch is against the latest dmd-1.x branch -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 2029] Typesafe variadic functions don't work in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=2029 --- Comment #5 from Tomas Lindquist Olsen to...@famolsen.dk 2009-11-18 03:46:13 PST --- I've attached a draft patch that replaces the typesafe variadic ast rewrites to something that works in any scope (and with ctfe). without the patch the following function: void foo(int[] arr ...) when called: foo(1,2,3); is rewritten as: int[3] _args; (_args[0] = 1, _args[1] = 2, _args[2] = 3, foo(_args[])); .. In global scope, this breaks, as you cannot assign to globals from ctfe, and in normal ctfe, breaks somehow as well. This patch changes the rewrite to: foo([1,2,3]); with each element being implicitly converted to the array element type. One downside is that codegen always allocates array literals on the heap, so it degrades performance a bit, but that needs to be fixed for http://d.puremagic.com/issues/show_bug.cgi?id=2356 as well (though it's probably a slightly different issue), and generally I'm not getting an impression that it's a concern (performance is secondary). In any case I added a new scopedLiteral field to ArrayLiteralExp so that codegen knows it's allowed to put the array on the stack if it wants to. Comments appreciated. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 2029] Typesafe variadic functions don't work in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=2029 Don clugd...@yahoo.com.au changed: What|Removed |Added Version|2.013 |1.020 --- Comment #2 from Don clugd...@yahoo.com.au 2009-09-15 07:30:43 PDT --- (In reply to comment #1) I'd like this to work too :) I guess I should make a patch ... I had a quick go at it before the last release. I didn't include it because it required changes outside of interpret.c. So I did member functions instead g. Should work on D1 as well. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 2029] Typesafe variadic functions don't work in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=2029 --- Comment #3 from Don clugd...@yahoo.com.au 2009-09-15 07:42:03 PDT --- (In reply to comment #2) (In reply to comment #1) I'd like this to work too :) I guess I should make a patch ... I had a quick go at it before the last release. I didn't include it because it required changes outside of interpret.c. So I did member functions instead g. Should work on D1 as well. To clarify: you can just comment out the lines near the top of interpret.c that displays the error message about typesafe variadics. But then you find that it doesn't compile, because it's trying to modify a global variable __arrayArg1. (The CTFE error messages make it a lot easier to understand what's happening g). Something similar happens with struct constructors, and I think it's wrong. It's more difficult to know how to fix it without breaking something else. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---