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

fixes #7906, array and openarray arg vs. ptr/ref generic #7909

Merged
merged 2 commits into from
Jun 4, 2018

Conversation

jangko
Copy link
Contributor

@jangko jangko commented May 30, 2018

No description provided.

compiler/sem.nim Outdated
# this will trigger an error later:
if result.isNil or result == a: return x
if result == b: return y
if k != tyNone:
# bug #7906
if k != tyNone and x.kind != tyGenericInst:
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment here explaining your reasoning. It seems fishy, why is tyGenericInst harmful here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add a comment.

the reason is

type
   GenericObject[T] = object
   GenericRefObject[T] = ref object
   
var a = GenericRefObject[int]          # tyGenericInst of ref object
var b = new(ref GenericObject[int]) # tyRef of tyGenericInst

from user perpective, a and b should be not too different, but inside the compiler, they are two different types.

so, if it already a tyGenericInst of ref object, it would be wrong to add more tyRef in front of it.
additional tyRef in the next compiler phase will generate ill formed AST.

@Araq Araq merged commit 069a53a into nim-lang:devel Jun 4, 2018
@jangko jangko deleted the fix7906 branch July 20, 2018 06:09
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