The following compiles without error on dmd2.055 head, although it includes casting shared(void*) to void* and const(void*) to void*. alias doesn't not have the same problems.
void main()
{
typedef void* A;
void AA(A a) {}
shared A a;
const A b;
AA(a);
AA(b);
}
Comment #1 by ibuclaw — 2011-08-29T09:38:19Z
I think this should sort it:
MATCH TypeTypedef::constConv(Type *to)
{
if (equals(to))
return MATCHexact;
- if (ty == to->ty && sym == ((TypeTypedef *)to)->sym)
- return sym->basetype->implicitConvTo(((TypeTypedef *)to)->sym->basetype);
+ if (ty == to->ty && sym == ((TypeTypedef *)to)->sym &&
+ MODimplicitConv(mod, to->mod))
+ return MATCHconst;
return MATCHnomatch;
}
Regards
Comment #2 by ibuclaw — 2011-08-29T09:49:39Z
Patch breaks std.encoding:
std/encoding.d:373: Error: cannot implicitly convert expression (s[0u]) of type const(AsciiChar) to AsciiChar
std/encoding.d:374: Error: cannot implicitly convert expression (s[0u]) of type const(AsciiChar) to AsciiChar
std/encoding.d:380: Error: cannot implicitly convert expression (s[__dollar - 1u]) of type const(AsciiChar) to AsciiChar
std/encoding.d:381: Error: cannot implicitly convert expression (s[__dollar - 1u]) of type const(AsciiChar) to AsciiChar
Other than that, it is all good to go. :)
Comment #3 by yebblies — 2011-08-29T11:08:03Z
It should break std.windows.registry too, that's where I found it.
Comment #4 by ibuclaw — 2011-08-31T15:44:04Z
I don't have windows so I can't test that. ;)
Everything is fine on the *nix side of things. For std.encoding, just replace the three 'typedef ubyte' with 'alias ubyte xxx'
Regards
Comment #5 by yebblies — 2011-08-31T22:22:20Z
(In reply to comment #4)
> I don't have windows so I can't test that. ;)
>
Since phobos and druntime don't use typedef any more, there should be no reliance on this bug any more. Would you like to make a pull request?
> Everything is fine on the *nix side of things. For std.encoding, just replace
> the three 'typedef ubyte' with 'alias ubyte xxx'
This didn't work for me for some reason, I think the module relies on them being distinct types. Using enums instead solved the problem.
Comment #6 by hoganmeier — 2011-12-30T06:47:54Z
A related issue is if const is part of the typedef.
typedef const(void*) type;
void bar(void* a) {}
void main()
{
type a;
bar(&a);
}
Comment #7 by bugzilla — 2012-01-20T23:38:39Z
First off, this is a D2, not a D1 issue. D
Comment #8 by bugzilla — 2012-01-20T23:39:39Z
... continued
D1 does not have shared/const, etc.
Secondly, typedefs are deprecated in D2. So this is "wontfix".