Comment #3 by bearophile_hugs — 2012-07-23T08:47:04Z
> void main(){
> immutable a = [1,2];
> int[a.length+0] b; // ok
> int[a.length ] c; // error
> }
>
> The code should compile.
That code should not compile, in my opinion.
Nor this one:
immutable a = [1, 2];
void main() {
int[a.length] b;
}
See some discussion:
http://forum.dlang.org/thread/[email protected]
Comment #4 by clugdbug — 2012-07-25T03:39:21Z
(In reply to comment #3)
> > void main(){
> > immutable a = [1,2];
> > int[a.length+0] b; // ok
> > int[a.length ] c; // error
> > }
> >
> > The code should compile.
>
> That code should not compile, in my opinion.
The rule is, in any circumstance where a compile-time value is required, it will attempt to interpret it at compile time. If it fails, it is an error.
> Nor this one:
>
> immutable a = [1, 2];
> void main() {
> int[a.length] b;
> }
No, that should *definitely* compile.
Global variables with initializers always have the initializer CTFE'd.
Comment #5 by bearophile_hugs — 2012-07-25T07:19:15Z
(In reply to comment #4)
> > That code should not compile, in my opinion.
>
> The rule is, in any circumstance where a compile-time value is required, it
> will attempt to interpret it at compile time. If it fails, it is an error.
I am not sure, but I think you are agreeing with me, so I mark this as a regression.
> Global variables with initializers always have the initializer CTFE'd.
OK.
(In reply to comment #5)
> (In reply to comment #4)
>
> > > That code should not compile, in my opinion.
> >
> > The rule is, in any circumstance where a compile-time value is required, it
> > will attempt to interpret it at compile time. If it fails, it is an error.
>
> I am not sure, but I think you are agreeing with me, so I mark this as a
> regression.
I was disagreeing with you.
Comment #8 by github-bugzilla — 2013-06-01T00:59:57Z