Bug 20499 – bad error message caused by UFCS attempt on the identifier matching to an import
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-01-11T08:20:40Z
Last change time
2023-10-16T08:57:46Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Basile-z
Comments
Comment #0 by b2.temp — 2020-01-11T08:20:40Z
a.d
---
module a;
class Foo
{
private int x;
}
---
---
module b;
import a;
void test(Foo foo)
{
foo.a++;
}
---
then in the same directory as the two files
$ dmd b.d
output:
> Error: function expected before `()`, not `module a` of type `void`
The real problem here is that `Foo` does not contain any member named a.
The bad message leads to think that the compiler tries a function `foo` on the import `a`, i.e by UFCS but the only existing `foo` is a class.
Also if you look at the command line you can note that "a.d" is not specified. I don't know why dmd automatically detects the file. If this is part of this strange issue then what is expected is
> module `a` is in file 'a.d' which cannot be read
Comment #1 by b2.temp — 2023-10-16T08:57:46Z
*** This issue has been marked as a duplicate of issue 10957 ***