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

Don't attempt to redeclare nesting scope #36

Merged
merged 1 commit into from
May 25, 2022
Merged

Conversation

jez
Copy link
Contributor

@jez jez commented May 3, 2022

Sorbet already knows how to handle

module A::B::C
end

out of the box. It doesn't require the programmer to write

module A; end
module A::B; end
module A::B::C
end

like you would have to if you were running this code like normal Ruby.

And this is important, because if it's ever the case that somewhere else
A or B are actually defined as classes, Sorbet is completely fine
with that:

# OK

module A; end
class A::B; end
module A::B::C
end

But if Sorbet ever sees conflicting definitions, then it will complain:

# ERROR

module A; end
class A; end

So we don't gain anything by having these declared explicitly, and also
in some cases it causes problems.

Sorbet already knows how to handle

    module A::B::C
    end

out of the box. It doesn't require the programmer to write

    module A; end
    module A::B; end
    module A::B::C
    end

like you would have to if you were running this code like normal Ruby.

And this is important, because if it's ever the case that somewhere else
`A` or `B` are actually defined as classes, Sorbet is completely fine
with that:

    # OK

    module A; end
    class A::B; end
    module A::B::C
    end

But if Sorbet ever sees conflicting definitions, then it will complain:

    # ERROR

    module A; end
    class A; end

So we don't gain anything by having these declared explicitly, and also
in some cases it causes problems.
@jez
Copy link
Contributor Author

jez commented May 25, 2022

@mdehoog if you have a moment for this I'd appreciate it 🙏

Copy link
Contributor

@mdehoog mdehoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice cleanup!

@mdehoog mdehoog merged commit 4c7eae1 into coinbase:master May 25, 2022
@jez jez deleted the jez-nesting branch April 26, 2023 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants