Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2022-01-06 Thread bauss via Digitalmars-d-learn
On Thursday, 6 January 2022 at 16:01:40 UTC, HuskyNator wrote: On Thursday, 6 January 2022 at 13:33:24 UTC, bauss wrote: While not the exact same, there's a small work around here that can help in some cases: ```d immutable long[string] aa; shared static this() { aa = [ "foo": 5,

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2022-01-06 Thread Tejas via Digitalmars-d-learn
On Thursday, 6 January 2022 at 16:01:09 UTC, Stefan Koch wrote: On Thursday, 6 January 2022 at 12:04:12 UTC, HuskyNator wrote: On Monday, 28 November 2016 at 14:41:44 UTC, Era Scarecrow wrote: On Monday, 28 November 2016 at 09:06:34 UTC, Paolo Invernizzi wrote: The point is that I was trying to

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2022-01-06 Thread HuskyNator via Digitalmars-d-learn
On Thursday, 6 January 2022 at 13:33:24 UTC, bauss wrote: While not the exact same, there's a small work around here that can help in some cases: ```d immutable long[string] aa; shared static this() { aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; } ``` Thanks a lot! I'v

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2022-01-06 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 6 January 2022 at 12:04:12 UTC, HuskyNator wrote: On Monday, 28 November 2016 at 14:41:44 UTC, Era Scarecrow wrote: On Monday, 28 November 2016 at 09:06:34 UTC, Paolo Invernizzi wrote: The point is that I was trying to avoid some cycle between modules, detected by 2.072. This bug l

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2022-01-06 Thread bauss via Digitalmars-d-learn
On Thursday, 6 January 2022 at 12:04:12 UTC, HuskyNator wrote: On Monday, 28 November 2016 at 14:41:44 UTC, Era Scarecrow wrote: On Monday, 28 November 2016 at 09:06:34 UTC, Paolo Invernizzi wrote: The point is that I was trying to avoid some cycle between modules, detected by 2.072. This bug l

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2022-01-06 Thread HuskyNator via Digitalmars-d-learn
On Monday, 28 November 2016 at 14:41:44 UTC, Era Scarecrow wrote: On Monday, 28 November 2016 at 09:06:34 UTC, Paolo Invernizzi wrote: The point is that I was trying to avoid some cycle between modules, detected by 2.072. This bug leads to pollution in the use of static this only to workaround

Re: non-constant expression while initializing two dim array

2020-06-08 Thread Basile B. via Digitalmars-d-learn
On Monday, 8 June 2020 at 06:37:18 UTC, tirithen wrote: How can I initialize my two dimensional array? When I try to run the code below I get the error: Error: non-constant expression ["user":[cast(Capability)0], "administrator":[cast(Capability)1]] Code:

non-constant expression while initializing two dim array

2020-06-07 Thread tirithen via Digitalmars-d-learn
How can I initialize my two dimensional array? When I try to run the code below I get the error: Error: non-constant expression ["user":[cast(Capability)0], "administrator":[cast(Capability)1]] Code: enum Capability { self, administer }

VibeD - RestInterfaceClient - non-constant expression

2017-07-24 Thread holo via Digitalmars-d-learn
TML template frontpage.dt... ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/inet/url.d(61,18): Error: non-constant expression "http://127.0.0.1:8090/api/"[0..4] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/inet/url.d(129,15): Error: non-constant expression "http://127.0.0.1:8090/

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2016-11-28 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 28 November 2016 at 09:06:34 UTC, Paolo Invernizzi wrote: The point is that I was trying to avoid some cycle between modules, detected by 2.072. This bug leads to pollution in the use of static this only to workaround the limitation... Wasn't someone working on a Associative Array

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2016-11-28 Thread Paolo Invernizzi via Digitalmars-d-learn
rt(aa["foo"] == 5); assert(aa["bar"] == 10); assert(aa["baz"] == 2000); } But results to: Error: non-constant expression ["foo":5L, "bar":10L, "baz":2000L] Known bug? If yes, Is there the need to emend the documentation, t

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2016-11-27 Thread John Colvin via Digitalmars-d-learn
10); assert(aa["baz"] == 2000); } But results to: Error: non-constant expression ["foo":5L, "bar":10L, "baz":2000L] Known bug? If yes, Is there the need to emend the documentation, till the bug is open? --- /Paolo Known bug. If you need a

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2016-11-27 Thread Paolo Invernizzi via Digitalmars-d-learn
On Saturday, 26 November 2016 at 19:57:21 UTC, Adam D. Ruppe wrote: On Saturday, 26 November 2016 at 17:37:57 UTC, Paolo Invernizzi wrote: This is stated in documentation [1]: What's the link? This is a known limitation, it has never worked. The docs should reflect that, though some day, it

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2016-11-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 26 November 2016 at 17:37:57 UTC, Paolo Invernizzi wrote: This is stated in documentation [1]: What's the link? This is a known limitation, it has never worked. The docs should reflect that, though some day, it might start working.

non-constant expression ["foo":5, "bar":10, "baz":2000]

2016-11-26 Thread Paolo Invernizzi via Digitalmars-d-learn
This is stated in documentation [1]: immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; unittest { assert(aa["foo"] == 5); assert(aa["bar"] == 10); assert(aa["baz"] == 2000); } But results to:

Re: constant expression

2016-02-24 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 23 February 2016 at 08:00:24 UTC, Nicholas Wilson wrote: Silly question. Why is this necessary? Due to a problem with the implementation, associative arrays currently can't be initialized statically. We hope it will eventually get fixed, but until then, you have to use module con

Re: constant expression

2016-02-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/23/16 3:00 AM, Nicholas Wilson wrote: On Tuesday, 23 February 2016 at 07:43:37 UTC, Ali Çehreli wrote: On 02/22/2016 11:38 PM, Nicholas Wilson wrote: I've tried with both mutable and immutable a module scope. Scope I want is global (don't care about mutability) Uncomment immutable if y

Re: constant expression

2016-02-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 23 February 2016 at 07:43:37 UTC, Ali Çehreli wrote: On 02/22/2016 11:38 PM, Nicholas Wilson wrote: I've tried with both mutable and immutable a module scope. Scope I want is global (don't care about mutability) Uncomment immutable if you want immutable and remove 'shared' if y

Re: constant expression

2016-02-22 Thread Ali Çehreli via Digitalmars-d-learn
On 02/22/2016 11:38 PM, Nicholas Wilson wrote: I've tried with both mutable and immutable a module scope. Scope I want is global (don't care about mutability) Uncomment immutable if you want immutable and remove 'shared' if you want multiple of this per thread (probably not). /* immutable

Re: constant expression

2016-02-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 23 February 2016 at 07:26:01 UTC, Ali Çehreli wrote: On 02/22/2016 09:52 PM, Nicholas Wilson wrote: How is this not a constant expression ? auto ctodtypes = [ "void" : "void", "uint32_t" : "uint", "uint64_t"

Re: constant expression

2016-02-22 Thread Ali Çehreli via Digitalmars-d-learn
On 02/22/2016 09:52 PM, Nicholas Wilson wrote: How is this not a constant expression ? auto ctodtypes = [ "void" : "void", "uint32_t" : "uint", "uint64_t" : "ulong", "int32_t" : "int",

constant expression

2016-02-22 Thread Nicholas Wilson via Digitalmars-d-learn
How is this not a constant expression ? auto ctodtypes = [ "void" : "void", "uint32_t" : "uint", "uint64_t" : "ulong", "int32_t" : "int", "int64_t" : "long", &

Re: Error: non-constant expression

2013-12-26 Thread Jakob Ovrum
On Thursday, 26 December 2013 at 08:35:58 UTC, Ali Çehreli wrote: Are those at module scope (i.e. outside of any function)? Although it can be argued that it should be possible to produce the initial value of b at compile time, it is currently not possible. To elaborate: the problem is not wi

Re: Error: non-constant expression

2013-12-26 Thread Ali Çehreli
b = init_b(); } void main() { import std.stdio; writefln("%(%s -> %s\n%)", b); } > When add "const": > > const auto a = [["test", "1"]]; > const auto b = a.map!(x=>tuple(x[1],x[0])).assocArray; > > Gives another error: > Er

Error: non-constant expression

2013-12-25 Thread Dfr
uot;test", "1"]]; const auto b = a.map!(x=>tuple(x[1],x[0])).assocArray; Gives another error: Error: non-constant expression ["1":"test"] Any idea what is wrong ?

Re: Integer constant expression expected instead of...

2013-09-01 Thread Era Scarecrow
Added: http://d.puremagic.com/issues/show_bug.cgi?id=10946

Re: Integer constant expression expected instead of...

2013-09-01 Thread Era Scarecrow
On Monday, 2 September 2013 at 01:19:44 UTC, bearophile wrote: Era Scarecrow: [code] enum fieldEntryLength = 4; //immutable fieldEntryLength = 4; //same issue alias immutable(char[fieldEntryLength]) NString; [/code] test.d(10): Error: Integer constant expression expected instead of

Re: Integer constant expression expected instead of...

2013-09-01 Thread bearophile
Era Scarecrow: [code] enum fieldEntryLength = 4; //immutable fieldEntryLength = 4; //same issue alias immutable(char[fieldEntryLength]) NString; [/code] test.d(10): Error: Integer constant expression expected instead of fieldEntryLength This breaks code that previously compiled. I

Integer constant expression expected instead of...

2013-09-01 Thread Era Scarecrow
[code] enum fieldEntryLength = 4; //immutable fieldEntryLength = 4; //same issue alias immutable(char[fieldEntryLength]) NString; [/code] test.d(10): Error: Integer constant expression expected instead of fieldEntryLength This breaks code that previously compiled. I really don'

Re: Error: non-constant expression...

2010-11-27 Thread Jérôme M. Berger
bearophile wrote: > Jonathan M Davis: > >> At present, I don't believe that associative arrays are valid CTFE > > You are wrong, the current situation with AAs is not so simple :-) > > > string foo(string k) { > string[string] map = ["bar" : "spam"]; > return map[k]; > } > enum string v

Re: Error: non-constant expression...

2010-11-26 Thread bearophile
> I may add something about this in bugzilla (the problem with enum AAs is > already present there). http://d.puremagic.com/issues/show_bug.cgi?id=5279

Re: Error: non-constant expression...

2010-11-26 Thread bearophile
Jonathan M Davis: > At present, I don't believe that associative arrays are valid CTFE You are wrong, the current situation with AAs is not so simple :-) string foo(string k) { string[string] map = ["bar" : "spam"]; return map[k]; } enum string v = foo("bar"); static assert(v == "spam")

Re: Error: non-constant expression...

2010-11-26 Thread Jonathan M Davis
On Friday 26 November 2010 11:16:08 spir wrote: > Hello, > > void f () { > static string[string] map = ["1":"un", "2":"du", "3":"tri"]; > } > ==> > Error: non-constant expression ["1":"u

Re: Error: non-constant expression...

2010-11-26 Thread spir
On Fri, 26 Nov 2010 16:17:10 -0500 bearophile wrote: > spir: > > > void f () { > > static string[string] map = ["1":"un", "2":"du", "3":"tri"]; > > } > > ==> > > Error: non-constant expres

Re: Error: non-constant expression...

2010-11-26 Thread bearophile
> In my mind there is some confusion about all this. Other people may give you > better answers. A solution in such situations is to take a look at the asm, that has confirmed my ideas: string first_function(string k) { immutable string[string] map1 = ["bar" : "spam"]; return map1[k];

Re: Error: non-constant expression...

2010-11-26 Thread bearophile
spir: > void f () { > static string[string] map = ["1":"un", "2":"du", "3":"tri"]; > } > ==> > Error: non-constant expression ["1":"un","2":"du","3":"tri&quo

Error: non-constant expression...

2010-11-26 Thread spir
Hello, void f () { static string[string] map = ["1":"un", "2":"du", "3":"tri"]; } ==> Error: non-constant expression ["1":"un","2":"du","3":"tri"] I do not understand w