Skip to content

Name resolving#2131

Merged
paf31 merged 1 commit into0.9from
name-resolving
May 22, 2016
Merged

Name resolving#2131
paf31 merged 1 commit into0.9from
name-resolving

Conversation

@garyb
Copy link
Copy Markdown
Member

@garyb garyb commented May 15, 2016

This is still WIP. Trickier than it first seemed, since it seems we introduce qualified names in a few places during desugaring, so when we do so we need to update the imports also... or something.

Resolves #1511, fixes #2148.

@paf31
Copy link
Copy Markdown
Contributor

paf31 commented May 15, 2016

Is this #1511?

@garyb
Copy link
Copy Markdown
Member Author

garyb commented May 15, 2016

Yep, although it also includes part of the proposal for #1901, as the requirements overlap: if you import M (x) you'll only get x in scope, not M.x as well as x.

I'm having second thoughts about that though, as it's partially what is causing the current failure... plus it will have to behave a bit differently for module re-exports to work as they do now, since if you import M (x) you can still export module M, even though M "doesn't exist" when resolving names in the module.

updateBinder s@(pos, _) (OpBinder op) =
(,) s <$> (OpBinder <$> updateValueOpName op pos)
updateBinder s (TypedBinder t b) = do
(s'@ (span', _), b') <- updateBinder s b
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was unnecessary, the traversal already steps into the binder (duh).

@garyb garyb force-pushed the name-resolving branch from be4231f to 28ca9b3 Compare May 16, 2016 01:09
updateType t = return t
updateInConstraint :: Constraint -> m Constraint
updateInConstraint (Constraint name ts info) =
Constraint <$> updateClassName name pos <*> pure ts <*> pure info
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Like that above case, need a different version of updateConstraints here that does not recurse on updateTypesEverywhere, as the traversal already does that.

These two traversal hiccups became apparent as the naming pass is even less idempotent than it was before. I'm pretty sure a case could be constructed that would cause both of these to fail.

@garyb
Copy link
Copy Markdown
Member Author

garyb commented May 16, 2016

Think I've got this figured out now. It's working the way where only exactly what you import can be referenced when it comes to values, types, etc. but you can still export SomeModule where SomeModule was not imported qualified. So import M (x) only introduces x, not M.x, as mentioned above.

The traversal cases I commented on are the thing that mainly broke this before (aside from an update needed to purescript-partial)... yeah, it took me this long to track them down!

@garyb
Copy link
Copy Markdown
Member Author

garyb commented May 16, 2016

The warnings causing the compile to fail should be fixed now.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.06%) to 55.867% when pulling 45449b1 on name-resolving into 4852b5d on 0.9.

@garyb garyb force-pushed the name-resolving branch from 45449b1 to 0c22d5d Compare May 16, 2016 10:14
@garyb
Copy link
Copy Markdown
Member Author

garyb commented May 16, 2016

...forgot to update extra-source-files. 15th time lucky?

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.06%) to 55.867% when pulling 0c22d5d on name-resolving into 4852b5d on 0.9.

@garyb garyb force-pushed the name-resolving branch from 0c22d5d to 0cc4c4d Compare May 20, 2016 16:15
@garyb
Copy link
Copy Markdown
Member Author

garyb commented May 20, 2016

Rebased for the recent merges.

@garyb garyb force-pushed the name-resolving branch from 0cc4c4d to 66c1f74 Compare May 20, 2016 17:14
@garyb
Copy link
Copy Markdown
Member Author

garyb commented May 20, 2016

Updated with a fix for #2148. It may also have been causing 2148. 😉

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.05%) to 56.574% when pulling 0cc4c4d on name-resolving into ca98825 on 0.9.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.06%) to 56.567% when pulling 66c1f74 on name-resolving into ca98825 on 0.9.

@paf31 paf31 merged commit cd4c708 into 0.9 May 22, 2016
@paf31 paf31 deleted the name-resolving branch May 22, 2016 18:26
@paf31
Copy link
Copy Markdown
Contributor

paf31 commented May 22, 2016

Looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants