• Eric Myhre's avatar
    Ok, I have learned a hard lesson about embedding. · f6e469ce
    Eric Myhre authored
    Fields in these structs are now named.  Embedding is reserved for
    things that are very explicitly supposed to carry their methods along.
    
    At some earlier point, I embedded the Type field in some of the
    generate structs because it saved me a few keystrokes in refactoring
    template strings.  This was not important.
    
    Today I learned: if you have embeddings which cause a name to be
    shadowed -- as the generateKindedRejections_String.Type field
    could shadow the generateKindString.Type field, for example -- if those
    resolve "neutrally" (I don't know if there's a better technical term
    for this), then... in that case, the templating system will be like
    "yeah, fine, whatev", and it works.  If you give one of those two
    fields a *separate type*, the templating system will now reject it as
    if no field of that name can be found.
    
    I encountered this while working on the generator for structs (which I
    *swear* I will commit any second now, when I stop finding prerequisite
    yaks to shave -- there have been many) and trying to use a more
    specialized TypeStruct instead of the Type interface.  Whee.
    
    I get the logic of this.  The error message could be better.
    
    Anyway: even though it technically didn't affect generateString (yet),
    making the change here for consistency with what's to come
    (including specializing the field even though there's currently no
    actual need for it).
    f6e469ce
genKindStringReprString.go 3.05 KB