Rock infers generic type exclusively from the first instance it can #825

Closed
shamanas opened this Issue Sep 21, 2014 · 6 comments

Projects

None yet

3 participants

@shamanas
Collaborator
Foo: class { init: func }
Bar: class extends Foo { init: super func }

f: func <T> (a, b: T) {
    T name println()
}

f (Bar new(), Foo new())

This should print Foo but it prints Bar, as T is infered from the first argument it appears in a.
Instead, findCommonRoot should be used here.

@fasterthanlime
Collaborator

Ooh, that looks good

screen shot 2015-07-09 at 22 39 33

@vendethiel

Just a question... what is the performance impact of such unification with say, an array literal of 500 elements?

@fasterthanlime
Collaborator

Ehhh now is not the time for such questions.

@fasterthanlime
Collaborator

(But it'd be interesting to make a stress test & optimize from there. Later.)

@fasterthanlime
Collaborator

So, there'll probably be about a dozen duplicates of this in the future.. but at least for this case, I have a fix.

I've tried going further but then the sdk starts showing cracks everywhere so uh, better left for another time. At least we're on the path to basic sanity.

@vendethiel

fair enough ;-)

@fasterthanlime fasterthanlime modified the milestone: 0.9.10 Jul 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment