Hello.
While building unittests for Vibe.d I'm hiting regression.
It happens both with ~master and ~2.065 branch.
DMD output:
---
Building configuration "unittest", build type unittest
Compiling...
source/vibe/internal/meta/funcattr.d(162): Error: undefined identifier foo
source/vibe/internal/meta/funcattr.d(133): Error: template instance vibe.internal.meta.funcattr.__unittestL155_69.AttributedParameterMetadata!(bar) error instantiating
source/vibe/internal/meta/funcattr.d(167): instantiated from here: IsAttributedParameter!(bar, "name1")
source/vibe/internal/meta/funcattr.d(167): Error: template instance vibe.internal.meta.funcattr.__unittestL155_69.IsAttributedParameter!(bar, "name1") error instantiating
source/vibe/internal/meta/funcattr.d(335): Error: undefined identifier attached1
source/vibe/internal/meta/funcattr.d(335): Error: undefined identifier attached2
source/vibe/internal/meta/funcattr.d(338): Error: template instance vibe.internal.meta.funcattr.__unittestL330_74.AttributedParameterMetadata!(foo) error instantiating
source/vibe/internal/meta/funcattr.d(721): Error: undefined identifier evaluator
source/vibe/internal/meta/funcattr.d(721): Error: undefined identifier evaluator
source/vibe/internal/meta/funcattr.d(721): Error: undefined identifier modificator
source/vibe/internal/meta/funcattr.d(777): Error: template instance vibe.internal.meta.funcattr.AttributedFunction!(sum, __T5GroupTAyaTAyaZ) error instantiating
source/vibe/internal/meta/funcattr.d(728): instantiated from here: createAttributedFunction!(sum, string, string)
source/vibe/internal/meta/funcattr.d(728): Error: template instance vibe.internal.meta.funcattr.createAttributedFunction!(sum, string, string) error instantiating
source/vibe/internal/meta/funcattr.d(753): Error: undefined identifier evaluator
source/vibe/internal/meta/funcattr.d(753): Error: undefined identifier evaluator
source/vibe/internal/meta/funcattr.d(753): Error: undefined identifier modificator
source/vibe/internal/meta/funcattr.d(777): Error: template instance vibe.internal.meta.funcattr.AttributedFunction!(sum, __T5GroupTAyaTAyaZ) error instantiating
source/vibe/internal/meta/funcattr.d(759): instantiated from here: createAttributedFunction!(sum, string, string)
source/vibe/internal/meta/funcattr.d(759): Error: template instance vibe.internal.meta.funcattr.createAttributedFunction!(sum, string, string) error instantiating
source/vibe/internal/meta/uda.d(72): Error: undefined identifier Attribute
source/vibe/internal/meta/uda.d(72): Error: undefined identifier Attribute
source/vibe/internal/meta/uda.d(75): Error: template instance vibe.internal.meta.uda.__unittestL68_84.findFirstUDA!(string, symbol) error instantiating
source/vibe/internal/meta/uda.d(100): Error: static assert (is(result0.value == Attribute)) is false
Error: DMD compile run failed with exit code 1
---
It works with 2.064.2 and with LDC2-2.065-b3-merge
Line at which DMD fails:
---
@before!foo("name1")
void bar(int name1, double name2)
{
}
---
Makes me believe that it is UDA related regression.
Link to full discussion:
https://github.com/rejectedsoftware/vibe.d/issues/526
Comment #1 by nazriel6969 — 2014-02-14T09:43:18Z
Command used for building vibe.d:
dub --config=unittest --build=unittest
Comment #2 by nazriel6969 — 2014-02-14T10:08:05Z
I think regression was introduced by:
https://github.com/D-Programming-Language/dmd/pull/3183
Building ~2.065 with # 61fee8a43142fb3e3cd504c413b16222c5d8abe4 (commit before pull #3183 was merged) and running Vibe.d unittest results in successful compilation & execution
Comment #3 by dlang-bugzilla — 2014-02-14T10:21:16Z
To be more precise, declarations inside unittest { } are not included in the scope of the new UDA semantic analysis.
pass:
int foo()
{
return 42;
}
unittest
{
@before!foo("name1")
}
fail:
unittest
{
int foo()
{
return 42;
}
@before!foo("name1")
}
Comment #5 by k.hara.pg — 2014-02-14T10:44:48Z
Reduced test case:
alias TypeTuple(T...) = T;
auto before(alias Hook)(string parameter_name)
{
return 0;
}
template checkUDAs(alias Function, string name)
{
alias attributes = TypeTuple!(
__traits(getAttributes, Function)
);
}
//int foo() { return 42; } // -> OK
void main()
{
int foo() { return 42; } // -> NG
@before!foo("name1")
void bar(int name1, double name2) {}
alias X = checkUDAs!(bar, "name1");
}