Thread overview | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 20, 2018 [Issue 18472] betterC: cannot use format at compile time. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18472 Mike Franklin <slavo5150@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |betterC CC| |slavo5150@yahoo.com -- |
February 20, 2018 [Issue 18472] betterC: cannot use format at compile time. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18472 --- Comment #1 from Mike Franklin <slavo5150@yahoo.com> --- The test doesn't compile with 2.078.3. 2.078.3 does not include the TypeInfo check, so at most this is a diagnostic regression. https://run.dlang.io/is/fvj8jb /dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.d(405): Error: static assert "Cannot put a const(char)[] into a Appender!string." /dlang/dmd/linux/bin64/../../src/phobos/std/format.d(1172): instantiated from here: put!(Appender!string, const(char)[]) /dlang/dmd/linux/bin64/../../src/phobos/std/format.d(473): instantiated from here: writeUpToNextSpec!(Appender!string) /dlang/dmd/linux/bin64/../../src/phobos/std/format.d(5831): instantiated from here: formattedWrite!(Appender!string, char, string, string) onlineapp.d(5): instantiated from here: format!(char, string, string) Do you have a test that will demonstrate a successful build prior to the TypeInfo check introduced in 2.079? -- |
February 20, 2018 [Issue 18472] [Reg 2.078] betterC: cannot use format at compile time. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18472 Martin Nowak <code@dawg.eu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |code@dawg.eu Summary|betterC: cannot use format |[Reg 2.078] betterC: cannot |at compile time. |use format at compile time. --- Comment #2 from Martin Nowak <code@dawg.eu> --- cat > bug.d << CODE import std.format; import std.stdio; void main() { enum s = "%1$s,%2$s".format("foo","bar"); writeln(s); } CODE dmd -c -betterC bug.d ---- /home/dawg/dlang/dmd-2.078.0/linux/bin64/../../src/phobos/std/range/primitives.d(405): Error: static assert "Cannot put a const(char)[] into a Appender!string." /home/dawg/dlang/dmd-2.078.0/linux/bin64/../../src/phobos/std/format.d(1172): instantiated from here: put!(Appender!string, const(char)[]) /home/dawg/dlang/dmd-2.078.0/linux/bin64/../../src/phobos/std/format.d(473): instantiated from here: writeUpToNextSpec!(Appender!string) /home/dawg/dlang/dmd-2.078.0/linux/bin64/../../src/phobos/std/format.d(5831): instantiated from here: formattedWrite!(Appender!string, char, string, string) /home/dawg/Code/D/bug.d(5): instantiated from here: format!(char, string, string) ---- Confirmed that this stopped to work with 2.078.0, the error looks rather weird, as betterC shouldn't change types. Also indeed with 2.079.0-beta.1 the error message is now about using TypeInfo. ---- /home/dawg/dlang/dmd-2.079.0-beta.1/linux/bin64/../../src/phobos/std/array.d(2889): Error: TypeInfo cannot be used with -betterC ---- The test case compiles fine with 2.077.1. -- |
February 21, 2018 [Issue 18472] [Reg 2.078] betterC: cannot use format at compile time. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18472 --- Comment #3 from Nicholas Wilson <iamthewilsonator@hotmail.com> --- (In reply to Martin Nowak from comment #2) > cat > bug.d << CODE > import std.format; > import std.stdio; > void main() > { > enum s = "%1$s,%2$s".format("foo","bar"); > writeln(s); > } > CODE > dmd -c -betterC bug.d > ---- > /home/dawg/dlang/dmd-2.078.0/linux/bin64/../../src/phobos/std/range/ > primitives.d(405): Error: static assert "Cannot put a const(char)[] into a > Appender!string." > /home/dawg/dlang/dmd-2.078.0/linux/bin64/../../src/phobos/std/format.d(1172): > instantiated from here: put!(Appender!string, const(char)[]) > /home/dawg/dlang/dmd-2.078.0/linux/bin64/../../src/phobos/std/format.d(473): > instantiated from here: writeUpToNextSpec!(Appender!string) > /home/dawg/dlang/dmd-2.078.0/linux/bin64/../../src/phobos/std/format.d(5831): > instantiated from here: formattedWrite!(Appender!string, char, string, > string) > /home/dawg/Code/D/bug.d(5): instantiated from here: format!(char, > string, string) > ---- > > Confirmed that this stopped to work with 2.078.0, the error looks rather weird, as betterC shouldn't change types. > Indeed that is issue 18101 which was fixed to check typeinfo, but now also fails at compile time. > Also indeed with 2.079.0-beta.1 the error message is now about using TypeInfo. > ---- > /home/dawg/dlang/dmd-2.079.0-beta.1/linux/bin64/../../src/phobos/std/array. d(2889): Error: TypeInfo cannot be used with -betterC > ---- > > The test case compiles fine with 2.077.1. That sounds about the right timeframe. -- |
February 21, 2018 [Issue 18472] [Reg 2.078] betterC: cannot use format at compile time. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18472 --- Comment #4 from Mike Franklin <slavo5150@yahoo.com> --- Isn't this then a duplicate of Issue 18101? In other words, if Issue 18101 were solved, there wouldn't be a need for TypeInfo, and therefore the TypeInfo error would not be triggered? -- |
February 21, 2018 [Issue 18472] [Reg 2.078] betterC: cannot use format at compile time. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18472 Mike Franklin <slavo5150@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://issues.dlang.org/sh | |ow_bug.cgi?id=18101 -- |
April 15, 2018 [Issue 18472] [Reg 2.078] betterC: cannot use format at compile time. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18472 Rainer Schuetze <r.sagitario@gmx.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |r.sagitario@gmx.de --- Comment #5 from Rainer Schuetze <r.sagitario@gmx.de> --- Here's a simpler test case: module betterc; enum b = typeid(size_t) is typeid(uint); >dmd -betterC -c betterc.d betterc.d(2): Error: TypeInfo cannot be used with -betterC -- |
April 15, 2018 [Issue 18472] [Reg 2.078] betterC: cannot use format at compile time. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18472 --- Comment #6 from Mike Franklin <slavo5150@yahoo.com> --- (In reply to Rainer Schuetze from comment #5) > Here's a simpler test case: > > module betterc; > enum b = typeid(size_t) is typeid(uint); At https://dlang.org/spec/betterc.html under the "Not Available" section: > 2. TypeInfo and ModuleInfo So, it is by design that any call to `typeid` is going to fail when compiled with `-betterC`. This specific issue is about not being able to use `format` in `-betterC`. Perhaps the reason for that is because `format` relies on runtime type information (i.e. TypeInfo). So the solution, specific to this issue, would not be allow uses of `typeid` in `-betterC`, but rather to remove the dependency of `format` on runtime type information (if that's even possible). D has excellent facilities for doing introspection at compile-time, so it may be possible to look to those facilities in concert with templates to find a solution that does not rely on runtime type information. It would likely also help to begin replacing compiler-generated calls to runtime hooks that depend on `TypeInfo` with templates. See also https://forum.dlang.org/post/mr7a65$2hc$1@digitalmars.com -- |
April 16, 2018 [Issue 18472] [Reg 2.078] betterC: cannot use format at compile time. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18472 --- Comment #7 from Rainer Schuetze <r.sagitario@gmx.de> --- I think the main issue is that the compiler does not distinguish between information needed at compile time and what's necessary inside the object file. -- |
April 16, 2018 [Issue 18472] [Reg 2.078] betterC: cannot use format at compile time. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18472 --- Comment #8 from Mike Franklin <slavo5150@yahoo.com> --- (In reply to Rainer Schuetze from comment #7) > I think the main issue is that the compiler does not distinguish between information needed at compile time and what's necessary inside the object file. Ok, I understand now: `enum b = typeid(size_t) is typeid(uint);` should be evaluated at compile time, and I the -betterC limitations should only apply at runtime. -- |
Copyright © 1999-2021 by the D Language Foundation