Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixImmutableConv: incompatible types for (foo) - (bar): both operands are of type const(SysTime) #4811

Open
zorael opened this issue Jan 1, 2025 · 1 comment

Comments

@zorael
Copy link

zorael commented Jan 1, 2025

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?

@kinke
Copy link
Member

kinke commented Jan 7, 2025

This isn't LDC-specific, DMD v2.110.0-beta.1 behaves identically: https://d.godbolt.org/z/azse4j14f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants