Bug 1479 – mixin error across two module

Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2007-09-06T08:10:05Z
Last change time
2019-08-15T10:08:46Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Haitong Xiao

Comments

Comment #0 by redsea — 2007-09-06T08:10:05Z
the following code would report: test.d(8): Error: identifier 'tpl' is not defined. but if combine the codes into one module, it could be successful compiled. this bug force me combine many code into one module. 1.018, 1.020, 1.021 all act same. file test.d ------------------- module test; import test1; template tpl() { alias S2!(tpl) tt; } void main() { S2!(tpl) v; } ------------------- file test1.d ------------------- module test1; struct S1(alias t1) { mixin t1!(); } struct S2(alias t) { alias S1!(t) mytype; int i; }
Comment #1 by matti.niemenmaa+dbugzilla — 2007-09-06T09:30:08Z
Comment #2 by razvan.nitu1305 — 2019-08-15T10:08:46Z
This bug is invalid. When you instantiate `S2!(tpl) v;` in main (test.d), the symbol tpl is visible, so there's no problem. Now when S2 needs to be instantiated you instantiate S1 with the alias symbol t which points to tpl. This is fine also, but when you instantiate S1, you mixin the code that is contained by the tpl template which is `alias S2!(tpl) tt;`, so your S1 becomes: struct S1 { alias S2!tpl tt; } but in the file test1.d there is no tpl symbol, therefore you end up with the correct issued error. To fix this you just have to import test.d. Closing as invalid.