Skip to content

cmd/internal/src: XPos.After doesn't necessarily match Pos.After #20390

@mdempsky

Description

@mdempsky

XPos.After (and XPos.Before) compares XPoses with different bases according to their base index, which is determined by the order they're added to the PosTable. I think this is worrying because we don't currently have any code in the compiler to ensure PosBase are registered in order.

Possible solutions I see:

  1. Change XPos.After's signature to take a *PosTable parameter and return the result of comparing the corresponding Pos values.
  2. Change package syntax's parser to register PosBase with the PosTable during parsing. (Will require locking.)
  3. Change package syntax's parser to collect all PosBase into a slice which we can register serially once parsing is done.

/cc @griesemer

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions