Bug 13718 – unary minus on number literals has lower precedence than UFCS

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-11-12T19:06:12Z
Last change time
2024-12-13T18:34:35Z
Assigned to
No Owner
Creator
Martin Nowak
Moved to GitHub: dmd#18911 →

Comments

Comment #0 by code — 2014-11-12T19:06:12Z
This is somewhat surprising when you think of the following. -2.sin `-sin(2)` instead of `sin(-2)` But OTOH it's consistent with so just explicitly explaining this in the docs would be enough IMO. -obj.val Definitely a problem is the compiler error for this. -2.toJson '(JSONValue __ctmp1507 = JSONValue; , __ctmp1507).this(2)' is not of arithmetic type, it is a JSONValue It should read something like 'unary minus cannot be applied to a JSONValue'.
Comment #1 by dlang-bot — 2023-09-20T15:47:30Z
@ntrel created dlang/dmd pull request #15620 "Improve invalid operator error message" mentioning this issue: - Improve invalid operator error message Show operation. Use 'is not defined' for aggregate types. Part of Issue 13718 - unary minus on number literals has lower precedence than UFCS. https://github.com/dlang/dmd/pull/15620
Comment #2 by dlang-bot — 2023-09-21T12:40:40Z
dlang/dmd pull request #15620 "Improve invalid operator error message" was merged into master: - 6a1f49b2cb786d8fd079aed528fd1ac97af024b7 by Nick Treleaven: Improve invalid operator error message Show operation. Use 'is not defined' for aggregate types. Part of Issue 13718 - unary minus on number literals has lower precedence than UFCS. https://github.com/dlang/dmd/pull/15620
Comment #3 by robert.schadek — 2024-12-13T18:34:35Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18911 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB