[Issue 20527] New: std.json CTFE cannot read integer
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 23 13:00:13 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20527
Issue ID: 20527
Summary: std.json CTFE cannot read integer
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: schveiguy at yahoo.com
std.json has a quirky implementation of integer parsing where it parses a ulong
for non-negative numbers, but then sets the tag to point at a long. This gives
CTFE fits because you are setting one member of a union, then reading a
different member.
Code to reproduce:
static assert(parseJSON(`{ "int": 2}`)["int"].integer == 2);
Error: reinterpretation through overlapped field integer is not allowed in CTFE
Easy to fix, set the correct union member.
--
More information about the Digitalmars-d-bugs
mailing list