Skip to content

Fixes on naming resolution#459

Merged
rodrigogribeiro merged 4 commits into
mainfrom
name-resolution-fix-adt
Jun 13, 2026
Merged

Fixes on naming resolution#459
rodrigogribeiro merged 4 commits into
mainfrom
name-resolution-fix-adt

Conversation

@rodrigogribeiro

Copy link
Copy Markdown
Collaborator
  • This PR fixes a bug in naming resolution which I discovered when testing the ABI encoding for algebraic types.

@rodrigogribeiro rodrigogribeiro requested a review from mbenke June 11, 2026 19:35

@mbenke mbenke left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good, couple minor nits

Comment on lines +551 to +574
(Just (Var d), Just TLocalVar) -> do
ct <- lookupName d
let qn = QualName d (pretty n)
case ct of
Just TClass -> pure (Var qn)
Just TModule -> do
qdt <- lookupName qn
case qdt of
Just TFunction -> pure (Var qn)
Just TDataCon -> Con <$> resolveQualifiedConstructorName d n <*> pure []
_ -> undefinedName n
_ -> pure (Var n)
(Just (Var d), Just TParameter) -> do
ct <- lookupName d
let qn = QualName d (pretty n)
case ct of
Just TClass -> pure (Var qn)
Just TModule -> do
qdt <- lookupName qn
case qdt of
Just TFunction -> pure (Var qn)
Just TDataCon -> Con <$> resolveQualifiedConstructorName d n <*> pure []
_ -> undefinedName n
_ -> pure (Var n)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove code duplication perhaps?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines +712 to +735
(Just (Var d), Just TLocalVar) -> do
ct <- lookupName d
let qn = QualName d (pretty n)
case ct of
Just TClass -> pure (Call Nothing qn es')
Just TModule -> do
qdt <- lookupName qn
case qdt of
Just TFunction -> pure (Call Nothing qn es')
Just TDataCon -> Con <$> resolveQualifiedConstructorName d n <*> pure es'
_ -> undefinedName n
_ -> pure (Call Nothing n es')
(Just (Var d), Just TParameter) -> do
ct <- lookupName d
let qn = QualName d (pretty n)
case ct of
Just TClass -> pure (Call Nothing qn es')
Just TModule -> do
qdt <- lookupName qn
case qdt of
Just TFunction -> pure (Call Nothing qn es')
Just TDataCon -> Con <$> resolveQualifiedConstructorName d n <*> pure es'
_ -> undefinedName n
_ -> pure (Call Nothing n es')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

code duplication again

case qdt of
Just TFunction -> pure (Var qn)
Just TDataCon -> Con <$> resolveQualifiedConstructorName d n <*> pure []
_ -> undefinedName n

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

might be better to include qualified name in the error message

@rodrigogribeiro rodrigogribeiro force-pushed the name-resolution-fix-adt branch from f71e947 to b899d51 Compare June 12, 2026 21:37
@rodrigogribeiro rodrigogribeiro merged commit 50a6739 into main Jun 13, 2026
4 checks passed
@rodrigogribeiro rodrigogribeiro deleted the name-resolution-fix-adt branch June 13, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants