Skip to content

union pseudo keyword is no longer accepted in enum variant position as of 2019-11-25 #66943

New issue

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

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

Already on GitHub? # to your account

Closed
CAD97 opened this issue Dec 2, 2019 · 6 comments · Fixed by #67078
Closed

union pseudo keyword is no longer accepted in enum variant position as of 2019-11-25 #66943

CAD97 opened this issue Dec 2, 2019 · 6 comments · Fixed by #67078
Assignees
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@CAD97
Copy link
Contributor

CAD97 commented Dec 2, 2019

playground

enum Rule {
    union,
}

Initially reported in arabidopsis/typescript-definitions#4 and then pest-parser/pest#429.

My best guess is #66592; cc @estebank

This issue has been assigned to @kamleshbhalui via this comment.

@CAD97 CAD97 changed the title union locational keyword is no longer accepted in enum variant position as of 2019-11-25 union pseudo keyword is no longer accepted in enum variant position as of 2019-11-25 Dec 2, 2019
@CAD97
Copy link
Contributor Author

CAD97 commented Dec 2, 2019

Interesting note: this does not apply to async when in edition=2015 mode.

@Mark-Simulacrum Mark-Simulacrum added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 2, 2019
@Centril
Copy link
Contributor

Centril commented Dec 2, 2019

Regression introduced in #66641. My bad... should have remembered that union is contextual!

The fix should be to make changes around here:

self.token.is_keyword(kw::Union)

You'll want to use look-ahead to ensure that an identifier follows union.

Also, add a regression test for enum A { union }, enum B { union {} }, and enum C { union() }.

@Centril Centril added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-high High priority labels Dec 2, 2019
@Dylan-DPC-zz
Copy link

@rustbot claim @kamleshbhalui

@rustbot
Copy link
Collaborator

rustbot commented Dec 2, 2019

Error: Parsing assign command in comment failed: ...tbot claim|error: expected end of command at >| @kamleshb...

Please let @rust-lang/release know if you're having trouble with this bot.

@Dylan-DPC-zz
Copy link

@rustbot assign @kamleshbhalui

@rustbot rustbot self-assigned this Dec 2, 2019
@estebank
Copy link
Contributor

estebank commented Dec 3, 2019

You'll need to change

    fn recover_nested_adt_item(&mut self, keyword: Symbol) -> PResult<'a, bool> {
        if self.token.is_keyword(kw::Enum) ||
            self.token.is_keyword(kw::Struct) ||
            self.token.is_keyword(kw::Union)
        {

to something along the lines of

    fn recover_nested_adt_item(&mut self, keyword: Symbol) -> PResult<'a, bool> {
        if (self.token.is_keyword(kw::Enum) ||
            self.token.is_keyword(kw::Struct) ||
            self.token.is_keyword(kw::Union))
            && self.look_ahead(1, |t| t.is_ident())
        {

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
6 participants