Skip to content

cmd/compile: better error message when generics are used with -lang=go1.17 #47818

Closed

Description

@mdempsky

Currently, when compiling with -G=3 -lang=go1.17, we run the types2 typechecker, but parse without the AllowGenerics flag. The result is when users try to write generic code, they'll get syntax error messages like unexpected [, expecting (, which seems to be a recurring source of confusion and leaves users (incl. expert Go users) uncertain of how to proceed.

I think we should probably instead always parse with AllowGenerics (at least when we're going to use types2), and have types2 report the usual allowVersion error messages if users try to use generics with go1.17 or earlier.

/cc @griesemer @findleyr

Activity

  1. added
    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.
    on Aug 19, 2021
  2. added this to the Go1.18 milestone on Aug 19, 2021
  3. griesemer commented on Aug 19, 2021

    @griesemer
    Contributor

    Agreed. This makes sense now that we're on 1.18. I will take care of this (but I'm ooo until next Monday).

  4. self-assigned this
    on Aug 19, 2021
  5. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    and removed
    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.
    on Aug 19, 2021
  6. gopherbot commented on Aug 25, 2021

    @gopherbot
    Contributor

    Change https://golang.org/cl/344871 mentions this issue: cmd/compile: always accept 1.18 syntax but complain if not 1.18

  7. locked and limited conversation to collaborators on Jun 23, 2023
  8. added a commit that references this issue on Apr 29, 2024
    4068fb6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions