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

typechecker: Overly fussy about never values yielded from match #1329

Open
AtkinsSJ opened this issue Jan 23, 2023 · 0 comments
Open

typechecker: Overly fussy about never values yielded from match #1329

AtkinsSJ opened this issue Jan 23, 2023 · 0 comments
Labels
enhancement New feature or request typechecker

Comments

@AtkinsSJ
Copy link
Member

AtkinsSJ commented Jan 23, 2023

This is fine:

checked_captures.push(match capture {
    ByValue(name, span) => CheckedCapture::ByValue(name, span)
    ByReference(name, span) => CheckedCapture::ByReference(name, span)
    ByMutableReference(name, span) => CheckedCapture::ByMutableReference(name, span)
    AllByReference(span) => {
        .compiler.panic("AllByReference capture should not be looked up by name")
    }
})

This is not, and gives us Type mismatch: expected ‘CheckedCapture’, but got ‘never’:

checked_captures.push(match capture {
    ByValue(name, span) => CheckedCapture::ByValue(name, span)
    ByReference(name, span) => CheckedCapture::ByReference(name, span)
    ByMutableReference(name, span) => CheckedCapture::ByMutableReference(name, span)
    AllByReference(span) => .compiler.panic("AllByReference capture should not be looked up by name")
})

This turns out to be intended behaviour: the short => foo syntax can only be used for yielding values. However, a nicer error message when a match has a type mismatch with never, would be very helpful! It should tell you that you need to wrap it in {}.

@AtkinsSJ AtkinsSJ added typechecker enhancement New feature or request labels Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request typechecker
Projects
None yet
Development

No branches or pull requests

1 participant