Bug 1775 – Unittest inside template allows template mixin of an already declared class.

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2008-01-09T05:59:41Z
Last change time
2019-12-20T10:14:36Z
Keywords
accepts-invalid
Assigned to
Walter Bright
Creator
danijans03

Comments

Comment #0 by danijans03 — 2008-01-09T05:59:41Z
The code below compiles but it shouldn't. A more complex version of this problem caused dmd to segfault. import std.stdio; void main() { } template ObjectException(T, U) { class T : Exception { private U instance; public U data() { return instance; } this(char[] msg) { super(msg); } this(char[] msg, U object) { super(msg); instance = object; } } unittest { class ImlException { } class test { } mixin ObjectException!(ImlException, test); test i = new test(); ImlException ex = new ImlException("Ok",i); writefln(ex.msg); } }
Comment #1 by fvbommel — 2008-01-11T05:50:10Z
Since the template is never instantiated[1] but is syntactically correct, the code inside it is never semantically checked and completely compiled. Moving the unittest outside of the template produces the following errors (when compiled with -unittest): === test.d(44): Error: no constructor for ImlException test.d(45): Error: no property 'msg' for type 'test.__unittest0.ImlException' === [1] outside of the template, at least; the nested unittest isn't instantiated until the template itself is instantiated and thus doesn't count since it won't go any further than syntax checking. Anyway, closing this as invalid since there's no reason for the code not to compile. I suggest you submit a new bug report if you can get it to segfault again; otherwise ask for help in digitalmars.D.learn...
Comment #2 by dlang-bot — 2019-12-20T10:14:36Z
dlang/dub pull request #1820 "Fix issue #1775: preBuildCommand does not take root into account" was merged into master: - f2c146489fe7ab65545e2bd4aa07be4573f939a2 by Geod24: Fix issue #1775: preBuildCommand does not take root into account This fixes the case reported, by passing the 'Package.path()' (which is forwarded by 'Dub.rootPath') to runCommand. https://github.com/dlang/dub/pull/1820