Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messages for non-matching elif/else statements #89920

Closed
thatbirdguythatuknownot mannequin opened this issue Nov 8, 2021 · 5 comments
Closed

Improve error messages for non-matching elif/else statements #89920

thatbirdguythatuknownot mannequin opened this issue Nov 8, 2021 · 5 comments
Labels
3.12 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@thatbirdguythatuknownot
Copy link
Mannequin

thatbirdguythatuknownot mannequin commented Nov 8, 2021

BPO 45759
Nosy @aroberge, @lysnikolaou, @pablogsal, @AlexWaygood, @thatbirdguythatuknownot
PRs
  • bpo-45759: Better error messages for non-matching 'elif'/'else' state… #29481
  • bpo-45759: Better error messages for non-matching 'elif'/'else' statements #29513
  • bpo-45759: Re: Better error messages for non-matching 'elif'/'else' statements #29775
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2021-11-08.23:51:38.287>
    labels = ['interpreter-core', 'type-bug', '3.10', '3.11']
    title = 'Improve error messages for non-matching `elif`/`else` statements'
    updated_at = <Date 2021-11-25.12:15:15.681>
    user = 'https://github.com/thatbirdguythatuknownot'

    bugs.python.org fields:

    activity = <Date 2021-11-25.12:15:15.681>
    actor = 'Crowthebird'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Parser']
    creation = <Date 2021-11-08.23:51:38.287>
    creator = 'Crowthebird'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45759
    keywords = ['patch']
    message_count = 2.0
    messages = ['405990', '405997']
    nosy_count = 5.0
    nosy_names = ['aroberge', 'lys.nikolaou', 'pablogsal', 'AlexWaygood', 'Crowthebird']
    pr_nums = ['29481', '29513', '29775']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45759'
    versions = ['Python 3.10', 'Python 3.11']

    @thatbirdguythatuknownot
    Copy link
    Mannequin Author

    thatbirdguythatuknownot mannequin commented Nov 8, 2021

    While fixing errors in a program, I encountered this:

    if a == b + 2:
        c = sqrt(b) + a**2
        elif a == b + 3:
        ^^^^
    SyntaxError: Invalid syntax

    It should be giving an IndentationError or a better error message at least.

    @thatbirdguythatuknownot thatbirdguythatuknownot mannequin added 3.10 only security fixes 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Nov 8, 2021
    @thatbirdguythatuknownot
    Copy link
    Mannequin Author

    thatbirdguythatuknownot mannequin commented Nov 9, 2021

    I'd like to expand this to more than just elif/else statements inside if` statement blocks and make an error for other cases as well. I currently have a PR that has a general error to accommodate those cases.

    @thatbirdguythatuknownot thatbirdguythatuknownot mannequin changed the title elif inside if block is a SyntaxError non-matching elif/else statements with uninformative errors Nov 9, 2021
    @AlexWaygood AlexWaygood changed the title non-matching elif/else statements with uninformative errors Improve error messages for non-matching elif/else statements Nov 9, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel iritkatriel added type-feature A feature request or enhancement 3.12 bugs and security fixes and removed type-bug An unexpected behavior, bug, or error 3.11 only security fixes 3.10 only security fixes labels Oct 7, 2022
    @iritkatriel
    Copy link
    Member

    CC @pablogsal .

    @erlend-aasland
    Copy link
    Contributor

    ISTM that error messages was improved in #29513. Can we close this as completed, or is there remaining actionable items?

    @erlend-aasland erlend-aasland added the pending The issue will be closed if no feedback is provided label Jan 5, 2024
    @lysnikolaou
    Copy link
    Contributor

    I think we can close this, yes.

    @erlend-aasland erlend-aasland removed the pending The issue will be closed if no feedback is provided label Jan 5, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.12 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants