Re: Is it a bug?

2019-10-01 Thread japplegame
GCC 4.7 and older successfully compiles this: union S { int a; float b; }; int main() { const S s = {.b = 1.0}; } Run

Re: Is it a bug?

2019-10-01 Thread Temtaime
@Araq Why should we enforce const in C? It must be enforced in Nim, not the backend, non?

Re: Is it a bug?

2019-09-30 Thread Araq
@mratsim I gave it a try but the root problem is that C++ compilers do not support "named fields in const unions" (yet?), a C99 addition. So you can only initialize the first field of a union and nothing else.

Re: Is it a bug?

2019-09-30 Thread mratsim
Can't we do the other way around, start supporting case objects properly across compile-time to runtime boundary? That would be very useful for both [nimbus](https://github.com/status-im/nimbus/blob/78714295dab4ead5e56c0048c46ae07d8bbed91a/nimbus/vm/interpreter/gas_costs.nim#L360-L361), as a co

Re: Is it a bug?

2019-09-30 Thread Araq
Fair enough, consider it done.

Re: Is it a bug?

2019-09-30 Thread japplegame
Then why don't you start the deprecation process?

Re: Is it a bug?

2019-09-29 Thread Araq
Actually you cannot use `case object` in `const` sections. The compiler can't enforce this currently because it would break existing code where it happens to work.

Re: Is it a bug?

2019-09-29 Thread mratsim
Yes, There are a couple of issues with variants set at compile-time and then used at runtime: * [https://github.com/nim-lang/Nim/issues/11862](https://github.com/nim-lang/Nim/issues/11862) * [https://github.com/nim-lang/Nim/issues/8015](https://github.com/nim-lang/Nim/issues/8015) * [ht

Is it a bug?

2019-09-29 Thread japplegame
In the following code assertion is failed. Looks like a bug. Should I create an issue? import macros type Kind = enum kind1, kind2 Foo = object case kind: Kind of kind1: val1: int of kind2: val2: int macro test(node: untype