• Matthew Dempsky's avatar
    cmd/compile: prevent untyped types from reaching walk · a3b3284d
    Matthew Dempsky authored
    We already require expressions to have already been typechecked before
    reaching walk. Moreover, all untyped expressions should have been
    converted to their default type by walk.
    
    However, in practice, we've been somewhat sloppy and inconsistent
    about ensuring this. In particular, a lot of AST rewrites ended up
    leaving untyped bool expressions scattered around. These likely aren't
    harmful in practice, but it seems worth cleaning up.
    
    The two most common cases addressed by this CL are:
    
    1) When generating OIF and OFOR nodes, we would often typecheck the
    conditional expression, but not apply defaultlit to force it to the
    expression's default type.
    
    2) When rewriting string comparisons into more fundamental primitives,
    we were simply overwriting r.Type with the desired type, which didn't
    propagate the type to nested subexpressions. These are fixed by
    utilizing finishcompare, which correctly handles this (and is already
    used by other comparison lowering rewrites).
    
    Lastly, walkexpr is extended to assert that it's not called on untyped
    expressions.
    
    Fixes #23834.
    
    Change-Id: Icbd29648a293555e4015d3b06a95a24ccbd3f790
    Reviewed-on: https://go-review.googlesource.com/98337Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
    a3b3284d
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...