Bug 19270 – is expression fails with function types

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-09-27T13:54:40Z
Last change time
2024-12-13T19:00:41Z
Keywords
C++
Assigned to
No Owner
Creator
Atila Neves
Moved to GitHub: dmd#19488 →

Comments

Comment #0 by atila.neves — 2018-09-27T13:54:40Z
The second static assert below fails and shouldn't since it's basically the same thing as the first one: ------- int foo(short, double) { return 42; } static assert(is(typeof(foo) == typeof(*(int function(short, double)).init))); static assert(is(typeof(foo) == typeof(*(int function(A0, double)).init)), A0); ------- Note that this works as expected: ------- static assert(is(typeof(&foo) == int function(A0, double), A0)); -------
Comment #1 by atila.neves — 2018-09-27T13:55:02Z
Tagged as "C++" since this is preventing me from translating C++ headers.
Comment #2 by razvan.nitu1305 — 2023-04-28T11:08:19Z
I don't know if this is intentional or not, but it seems that this form of is expressions only work for the first of AST nesting.
Comment #3 by nick — 2023-10-29T11:36:32Z
I think `is` should support function types directly: is(typeof(foo) == int(short, double)) That might be easier to pattern match for A0. AFAICT writing a function type is only allowed as the target of an alias declaration.
Comment #4 by b2.temp — 2023-10-29T15:08:45Z
> writing a function type is only allowed as the target of an alias declaration. Yes, the reson of this restriction is that in the past the old AliasDecl syntax, i.e the one with out `=`, supported expressing a function type but not the new one. Moving the code to parse function types everywhere should be trivial but it is true that it's not much required in usual D code.
Comment #5 by robert.schadek — 2024-12-13T19:00:41Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19488 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB