This needs to be fixed

monkyyy crazymonkyyy at gmail.com
Sun Aug 25 18:11:05 UTC 2024


On Sunday, 25 August 2024 at 17:27:33 UTC, Manu wrote:
> 
> But that just leads to the question; what's with `b` then?

I believe its a struct offset

I dont understand the usecase, but it goes into traits
```
struct S{
	int x,y;
}
struct S_{
	int y,x;
}
unittest{
	import std;
	S s;
	alias b = s.x;
	S_ s_;
	__traits(child, s, b)=1;//works
	//__traits(child, s_, b)=1;//errors, when S_.y is also an int in 
the same place and a S_.x exists *grumble*
}
```
> Why did `b` emit the error eagerly at the assignment, but `d` 
> decided to
> take a lazy approach as you say?

aliases can be lazy if they reference a lazy compilation error

```d
alias Seq(T...)=T;
template foo(int i){
	void foo()(){
		static if(i==1){
			static assert(0);
		}
		import std;
		i.writeln;
	}
}
template bar(int i){
	alias foobar=Seq!(foo!i);
	alias bar=foobar[0];
}
unittest{
	alias barfoo=bar!1;
	bar!2;
}
```


More information about the Digitalmars-d mailing list