Constant_declarations spec

Hello,

https://golang.org/ref/spec#Constant_declarations

According to the grammar defined in the link above, the statement ‘const toto’ could compile (or in other words, is idiomatic) . This is wrong and thanks God the Golang indeed throw a compilation error.

Regards,

It is valid if it comes after another declaration. See these examples

https://play.golang.org/p/VCMAQzEulkJ

and

https://play.golang.org/p/tNJUYkP0Gsm

2 Likes

Yes, indeed.

But, like I said, the statement “const toto” is considered valid based on the grammar, which is wrong in practice.

https://play.golang.org/p/Il6Rk-SqzaS

This snippet is not working, but the constant_declartions section says it’s valid.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.