ldc
ldc copied to clipboard
fixImmutableConv: incompatible types for `(foo) - (bar)`: both operands are of type `const(SysTime)`
EndeavourOS/Arch x86_64, ldc v1.40.0 installed with the install.sh script.
LDC - the LLVM D compiler (1.40.0):
based on DMD v2.110.0 and LLVM 18.1.8
built with LDC - the LLVM D compiler (1.39.0)
Default target: x86_64-pc-linux-gnu
Host CPU: alderlake
I'm trying out the preview switches and came across some code that, with -preview=fixImmutableConv, compiles with dmd (v2.109.1) but not with ldc.
Reduced;
import std.datetime.systime;
void main()
{
const foo = Clock.currTime;
const bar = Clock.currTime;
const baz = foo - bar;
}
$ ~/dlang/ldc-1.40.0/bin/ldc2 -preview=fixImmutableConv test.d
test.d(7): Error: incompatible types for `(foo) - (bar)`: both operands are of type `const(SysTime)`
The same happens if I make them immutable, and I'm using immutable SysTimes everywhere in my project. While reducing I encountered similar errors with non-mutable JSONValues.
Should this not work?
This isn't LDC-specific, DMD v2.110.0-beta.1 behaves identically: https://d.godbolt.org/z/azse4j14f