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

Inliner chokes on sum #66

Open
julianhyde opened this issue Sep 16, 2021 · 0 comments
Open

Inliner chokes on sum #66

julianhyde opened this issue Sep 16, 2021 · 0 comments

Comments

@julianhyde
Copy link
Collaborator

The Inliner throws on a program with sum in the group clause. This program fails:

fun mapReduce2 mapper reducer list =
  from e in list,
      (k, v) in mapper e
    group k compute c = sum of v;

with

java.lang.ClassCastException: class net.hydromatic.morel.type.TypeVar cannot be cast to class net.hydromatic.morel.type.PrimitiveType (net.hydromatic.morel.type.TypeVar and net.hydromatic.morel.type.PrimitiveType are in unnamed module of loader 'app')
 at net.hydromatic.morel.eval.Codes.lambda$static$6(Codes.java:1454)
 at net.hydromatic.morel.compile.Inliner.visit(Inliner.java:90)
 at net.hydromatic.morel.ast.Core$Id.accept(Core.java:459)
 at net.hydromatic.morel.ast.Shuttle.visit(Shuttle.java:369)
 at net.hydromatic.morel.ast.Core$Aggregate.accept(Core.java:1126)

while this similar program succeeds:

fun int_sum [] = 0
  | int_sum (x :: xs) = x + (int_sum xs);
val int_sum = fn : int list -> int

fun mapReduce2 mapper reducer list =
  from e in list,
      (k, v) in mapper e
    group k compute c = int_sum of v;
val mapReduce2 = fn
   : ('a -> ('b * int) list) -> 'c -> 'a list -> {c:int, k:'b} list

I think the problem is that Relational.sum has a polymorphic type (which we convert to either int or real during type inference).

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

No branches or pull requests

1 participant