def A = 1z;
export type b = [A]int; // this should error out
Hm, I'm not actually sure if this is a good idea.
There isn't any technical reason why this should be disallowed, since constants are just substituted with their value. The actual justification for this (at least as I see it) is so tools like haredoc don't expose unexported declarations within the type.
The lack of a technical justification makes this less compelling though, especially with constant declarations being allowed as expressions:
fn f() void = { let x = if (true) { def FOO = 4; yield [0...]: [FOO]int; } else void; x as [4]int; };The above code is currently allowed, as I think it should be. There's not really a good reason not to allow it. But if we allow this, then the consistent thing to do here would be to allow it within exported types as well.
yeah i'm also not convinced this is a good idea tbh
Any objections to closing this as WONT_FIX?
This decision implies exported types may depend on nonexported types transitively through an expression:
type x = void; export type y = [3: (size | x): size]uint;I guess we're also fine with that? I'm asking because default values for optional parameters are another place where such things can pop up - so far we only had @offset and array length.
Hm, yeah, good point. I think that's fine? It's easier to allow it than not to, and it doesn't cause any problems, so I don't think it's worth disallowing.
Definitely gonna steal this example for my spec examples patch though lol