You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we look at the spec, for example, of the if statement, we can see it explicitly says a semicolon is required to separate the statement from the expression. In practice, a newline is also correct as can be seen in the following link.
Same happens with for init; cond; incr { statements and, well, every other place that requires a semicolon.
What did you expect to see?
That newlines are not correct in places where ; are required.
What did you see instead?
They are.
I assume this is because go/scanner uses the token type token.SEMICOLON for both semicolons and new lines. Maybe this is working as expected, but then the spec should say that either a semicolon or a newline are possible delimiters.
The text was updated successfully, but these errors were encountered:
If you look at the spec, you will also see that each statement in a statement list needs to be explicitly terminated by a semicolon (https://golang.org/ref/spec#Block) - yet we don't need to write them.
What version of Go are you using (
go version
)?go version go1.7.5 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GORACE=""
GOROOT="/usr/lib/golang"
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build324900564=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
What did you do?
If we look at the spec, for example, of the
if
statement, we can see it explicitly says a semicolon is required to separate the statement from the expression. In practice, a newline is also correct as can be seen in the following link.https://play.golang.org/p/_yCCtgJLpB
Same happens with
for init; cond; incr {
statements and, well, every other place that requires a semicolon.What did you expect to see?
That newlines are not correct in places where
;
are required.What did you see instead?
They are.
I assume this is because
go/scanner
uses the token typetoken.SEMICOLON
for both semicolons and new lines. Maybe this is working as expected, but then the spec should say that either a semicolon or a newline are possible delimiters.The text was updated successfully, but these errors were encountered: