• Robert Griesemer's avatar
    go_spec: don't allow parens around the literal type of composite literals · 07cc6440
    Robert Griesemer authored
    Background: The current spec is imprecise with respect to the parsing ambiguity
    for composite literals: It says that the ambiguity arises when the TypeName form
    of the LiteralType is used. The following code:
    
        if (B) {} ...
    
    is not using the TypeName form (but the parenthesized TypeName form) and thus
    could be interpreted as:
    
        if ((B){}) ...
    
    instead of
    
        if B {} ...
    
    Both compilers and gofmt choose the latter interpretation. One could fix the
    spec by making the clause regarding the parsing ambiguity more precise ("...using
    the _possibly parenthesized_ TypeName form of the LiteralType..."). The alternative
    (chosen here) is to simply disallow parenthesized literal types. Except for a single
    test case (test/parentype.go) there appears to be no Go code under $GOROOT containing
    parenthesized literal types. Furthermore, parentheses are never needed around a
    literal type for correct parsing.
    
    R=golang-dev
    CC=golang-dev
    https://golang.org/cl/1913041
    07cc6440
Name
Last commit
Last update
..
codelab/wiki Loading commit data...
codewalk Loading commit data...
devel Loading commit data...
gopher Loading commit data...
progs Loading commit data...
talks Loading commit data...
GoCourseDay1.pdf Loading commit data...
GoCourseDay2.pdf Loading commit data...
GoCourseDay3.pdf Loading commit data...
Makefile Loading commit data...
code.html Loading commit data...
codereview_with_mq.html Loading commit data...
contribute.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...
go_faq.html Loading commit data...
go_for_cpp_programmers.html Loading commit data...
go_lang_faq.html Loading commit data...
go_learning.html Loading commit data...
go_mem.html Loading commit data...
go_programming_faq.html Loading commit data...
go_spec.html Loading commit data...
go_tutorial.html Loading commit data...
go_tutorial.txt Loading commit data...
godocs.js Loading commit data...
htmlgen.go Loading commit data...
install.html Loading commit data...
logo-153x55.png Loading commit data...
makehtml Loading commit data...
popups.js Loading commit data...
prog.sh Loading commit data...
root.html Loading commit data...
sieve.gif Loading commit data...
style.css Loading commit data...
video-snap-fastcompiles.jpg Loading commit data...
video-snap-gocoding.jpg Loading commit data...
video-snap-io.jpg Loading commit data...
video-snap-oscon.jpg Loading commit data...