Skip to content

cmd/compile: const decl with missing RHS interpreted subtly differently with 1.18 #49157

@zigo101

Description

@zigo101

The current spec says:

Within a parenthesized const declaration list the expression list may be omitted from any but the first ConstSpec. Such an empty list is equivalent to the textual substitution of the first preceding non-empty expression list and its type if any. Omitting the list of expressions is therefore equivalent to repeating the previous list.

By the explanation, the following two declarations are equivalent but are not actually (assume they are in local blocks):

const (
    A = iota
    iota = iota
    B
    C
)
const (
    A = iota
    iota = iota
    B = iota
    C
  )

It would be better to change "textual" into "lexical".

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.release-blocker

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions