variable x cannot be read at compile time (ctfe)

maarten van damme maartenvd1994 at gmail.com
Mon Dec 17 11:57:56 PST 2012


Thanks, I'm really happy it works now.

it's odd that the resulting arraylist is slower to access at runtime
then the arraylist generated at runtime... Is there a reason for this?

Should I open bugreports for your testcases?

2012/12/17 bearophile <bearophileHUGS at lycos.com>:
>> I think it's a problem of nested delegates at CT. But if this is the
>> problem, dmd used to give a more clear error message.
>
>
> Two minimized programs that show the problems:
>
> -------------
>
> import std.algorithm: filter;
> import std.array: array;
> auto foo(in int x) {
>     return [1, 2].filter!(i => x)();
> }
> enum a = foo(3).array();
> void main() {}
>
>
>
> temp.d(4): Error: variable x cannot be read at compile time
>
> -------------
>
> import std.array: array;
> enum a = [1, 2].array();
> void main() {}
>
>
>
> ...\src\druntime\import\core\memory.d(251): Error:
> gc_malloc cannot be interpreted at compile time, because it has no available
> source code
>
> -------------
>
> Bye,
> bearophile


More information about the Digitalmars-d-learn mailing list