On Sun, Mar 16, 2025 at 2:30 PM 'Christophe Meessen' via golang-nuts <golang-nuts@googlegroups.com> wrote:
> You'll find the minimal example code generating the compilation error > here: https://go.dev/play/p/Vb-dNr2DpzM > > It is easy to get around it as the example shows. Why is the compiler > considering this as an error ? See https://go.dev/ref/spec#Composite_literals """" A parsing ambiguity arises when a composite literal using the TypeName form of the LiteralType appears as an operand between the keyword and the opening brace of the block of an "if", "for", or "switch" statement, and the composite literal is not enclosed in parentheses, square brackets, or curly braces. In this rare case, the opening brace of the literal is erroneously parsed as the one introducing the block of statements. To resolve the ambiguity, the composite literal must appear within parentheses. """" -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CAA40n-XaminyXRScGbPjnytnOstfCGLs%3D9xD%2BjPkpz4f52J0hQ%40mail.gmail.com.