Bug 23749 – Can't writeln a static array of strings with -preview=dip1000

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-02-27T21:49:35Z
Last change time
2023-02-27T22:24:19Z
Assigned to
No Owner
Creator
Paul Backus

Comments

Comment #0 by snarwin+bugzilla — 2023-02-27T21:49:35Z
As of DMD 2.102.1, the following program fails to compile when using -preview=dip1000: --- import std.stdio; void main() @safe { string[1] a = ["hello"]; writeln(a); } --- The error message is: --- bug.d(6): Error: `@safe` function `D main` cannot call `@system` function `std.stdio.writeln!(string[1]).writeln` /usr/include/dmd/phobos/std/stdio.d(1708): which calls `std.stdio.File.write!(string[1], char).write` /usr/include/dmd/phobos/std/format/write.d(527): which calls `std.format.write.formattedWrite!(LockingTextWriter, char, string[1]).formattedWrite` /usr/include/dmd/phobos/std/format/write.d(1231): which calls `std.format.write.formatValue!(LockingTextWriter, string[1], char).formatValue` /usr/include/dmd/phobos/std/format/internal/write.d(1340): which calls `std.format.internal.write.formatValueImpl!(LockingTextWriter, string[1], char).formatValueImpl` /usr/include/dmd/phobos/std/format/internal/write.d(1344): which was inferred `@system` because of: /usr/include/dmd/phobos/std/format/internal/write.d(1344): reference to local variable `obj` assigned to non-scope parameter `obj` calling `formatValueImpl` /usr/include/dmd/phobos/std/stdio.d(4209): `std.stdio.writeln!(string[1]).writeln` is declared here ---
Comment #1 by snarwin+bugzilla — 2023-02-27T22:24:19Z
No error when using DMD+Phobos master, so it looks like this has already been fixed.