New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question / proposal-maybe] resolving the @typeName of types in struct fields (eg. for ad-hoc/non-pkg-based sub-namespacing) #4330
Comments
Shouldn't the output be:
(or more specialized variants thereof) ? |
Yeah what I would expect by default as of today --- although the other, "future proposal/suggestion" half of this issue would be whether to consider a (sugary, admittedly) |
Not quite seeing the use-case. If you want the parent type, why are you asking about it from its members? |
A use-case? Here's a funky namespace of co-related struct types, to be sep'd out clearly from various other structs in the same .zig file (also not to be scattered into a different .zig file just for the namespacing purposes) pub const OurApiSpec = .{
.IncomingRequest = union(enum) {
negate: fn (Arg(i64)) Ret(i64),
hostName: fn (Arg(void)) Ret(String),
envVarValue: fn (Arg(String)) Ret(String),
},
.OutgoingRequest = union(enum) {
pow2: Req(i64, i64),
rnd: Req(void, f32),
add: Req(struct {
a: i64,
b: i64,
}, i64),
},
.IncomingNotification = union(enum) {
timeInfo: fn (Arg(TimeInfo)) void,
shuttingDown: fn (Arg(void)) void,
},
.OutgoingNotification = union(enum) {
envVarNames: []String,
shoutOut: bool,
},
}; (Above things sound silly because it's a demo/dummy/test setup for a protocol-handling lib that one then can use to also model real RPC protocols, not mock ones.) Then later for logging / prints / tracing / compileError messages etc.pp. you want to see either |
- generic "struct:L:C" naming if rloc is NodeTypeStructValueField - generic "struct:L:C" naming if rloc is NodeTypeFnCallExpr - move some tests from test/behavior/misc to test/behavior/typename closes ziglang#4330 closes ziglang#9339
- generic "struct:L:C" naming if rloc is NodeTypeStructValueField - generic "struct:L:C" naming if rloc is NodeTypeFnCallExpr - move some tests from test/behavior/misc to test/behavior/typename closes ziglang#4330 closes ziglang#9339
- generic "struct:L:C" naming if rloc is NodeTypeStructValueField - generic "struct:L:C" naming if rloc is NodeTypeFnCallExpr - move some tests from test/behavior/misc to test/behavior/typename closes ziglang#4330 closes ziglang#9339
Consider:
Output:
Not terribly critical in the current scheme of things, but would suggest as an "around-or-post 1.0 contributor-friendly rather-nice-to-have" longer-term to look into. (Or when self-hosting-comp is up and such subtleties / corner-cases become more immediately attackable.)
Or maybe it's just an accepted limitation of
typeName
, then feel free to close. Referencing in the field value another type name instead of anon/inline type-def "works" after all --- although then maybetypeName
should rather act like with any other anon/inline type-def not ever anywhere named!The text was updated successfully, but these errors were encountered: