• griesemer's avatar
    spec: clarify context type for certain non-constant shifts · 9690d245
    griesemer authored
    The spec is not conclusive about whether a non-constant shift of
    certain untyped constant left operands is valid when the shift
    expression appears as an index in an index or slice expression,
    or as a size in a `make` function call.
    
    Despite identical spec rules in all these cases, cmd/compile accepts
    
    	make([]byte, 1.0 << s)
    
    but pronounces an error for
    
    	a[1.0 << s]
    
    (go/types accepts both).
    
    This change clarifies the spec by explicitly stating that an
    untyped constant left operand in a non-constant shift (1.0 in
    the above examples) will be given type `int` in these contexts.
    
    A separate issue #21693 addresses the cmd/compile bug.
    
    Fixes #14844.
    
    Change-Id: I4b52125e487a607fae377fcbed55463cdce9836c
    Reviewed-on: https://go-review.googlesource.com/60230Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    9690d245
Name
Last commit
Last update
..
articles Loading commit data...
codewalk Loading commit data...
devel Loading commit data...
editors Loading commit data...
gopher Loading commit data...
play Loading commit data...
progs Loading commit data...
asm.html Loading commit data...
cmd.html Loading commit data...
code.html Loading commit data...
conduct.html Loading commit data...
contrib.html Loading commit data...
contribute.html Loading commit data...
debugging_with_gdb.html Loading commit data...
docs.html Loading commit data...
editors.html Loading commit data...
effective_go.html Loading commit data...
gccgo_contribute.html Loading commit data...
gccgo_install.html Loading commit data...
go-logo-black.png Loading commit data...
go-logo-blue.png Loading commit data...
go-logo-white.png Loading commit data...
go1.1.html Loading commit data...
go1.2.html Loading commit data...
go1.3.html Loading commit data...
go1.4.html Loading commit data...
go1.5.html Loading commit data...
go1.6.html Loading commit data...
go1.7.html Loading commit data...
go1.8.html Loading commit data...
go1.9.html Loading commit data...
go1.html Loading commit data...
go1compat.html Loading commit data...
go_faq.html Loading commit data...
go_mem.html Loading commit data...
go_spec.html Loading commit data...
help.html Loading commit data...
ie.css Loading commit data...
install-source.html Loading commit data...
install.html Loading commit data...
root.html Loading commit data...
security.html Loading commit data...
share.png Loading commit data...
tos.html Loading commit data...