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

Type checker doesn't reject parametrised shared functions #3519

Closed
borovan opened this issue Oct 25, 2022 · 15 comments
Closed

Type checker doesn't reject parametrised shared functions #3519

borovan opened this issue Oct 25, 2022 · 15 comments

Comments

@borovan
Copy link
Contributor

borovan commented Oct 25, 2022

with 0.7.1

image

doing silly generic tests and

my god our life would be easier if this could work :)


Fatal error: exception "Assert_failure mo_types/typ_hash.ml:123:27"
Raised at Mo_types__Typ_hash.go.(fun) in file "mo_types/typ_hash.ml", line 123, characters 27-53
Called from Stdlib__list.iter in file "list.ml", line 110, characters 12-15
Called from Mo_types__Typ_hash.go in file "mo_types/typ_hash.ml", line 123, characters 4-58
Called from ExpGraph.unfold.go in file "lang_utils/expGraph.ml", line 92, characters 22-28
Called from Stdlib__list.map in file "list.ml", line 92, characters 20-23
Called from Stdlib__list.map in file "list.ml", line 92, characters 32-39
Called from Stdlib__list.map in file "list.ml", line 92, characters 32-39
Called from Stdlib__list.map in file "list.ml", line 92, characters 32-39
Called from Stdlib__list.map in file "list.ml", line 92, characters 32-39
Called from Stdlib__list.map in file "list.ml", line 92, characters 32-39
Called from ExpGraph.unfold.go in file "lang_utils/expGraph.ml", line 93, characters 18-34
Called from ExpGraph.unfold in file "lang_utils/expGraph.ml", line 97, characters 10-17
Called from Mo_types__Typ_hash.typ_hash in file "mo_types/typ_hash.ml", line 164, characters 11-25
Called from Stdlib__list.map in file "list.ml", line 92, characters 20-23
Called from Mo_types__Typ_hash.typ_seq_hash in file "mo_types/typ_hash.ml" (inlined), line 167, characters 19-41
Called from Codegen__Compile.BumpStream.name_for in file "codegen/compile.ml", line 4648, characters 50-74
Called from Codegen__Compile.MakeSerialization.serialize in file "codegen/compile.ml", line 5838, characters 15-43
Called from Codegen__Compile.compile_prim_invocation in file "codegen/compile.ml", line 9023, characters 6-36
Called from Codegen__Compile.compile_exp in file "codegen/compile.ml", line 9120, characters 4-54
Called from Codegen__Compile.compile_exp_as in file "codegen/compile.ml", line 9253, characters 24-44
Called from Codegen__Compile.FuncDec.compile_local_function.(fun) in file "codegen/compile.ml", line 6900, characters 20-37
Called from Codegen__Compile.Func.of_body in file "codegen/compile.ml", line 764, characters 6-18
Called from CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 31, characters 17-27
Re-raised at CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 36, characters 4-11
Called from Lib.AllocOnUse.use in file "lib/lib.ml", line 527, characters 13-28
Called from Codegen__Compile.StackRep.materialize_const_v in file "codegen/compile.ml", line 6574, characters 58-69
Called from Lib.Promise.lazy_value in file "lib/lib.ml", line 469, characters 14-18
Called from Codegen__Compile.StackRep.adjust.(fun) in file "codegen/compile.ml", line 6612, characters 51-78
Called from Stdlib__list.map in file "list.ml", line 92, characters 20-23
Called from Codegen__InstrList.concat_map in file "codegen/instrList.ml" (inlined), line 133, characters 43-58
Called from Codegen__Compile.StackRep.adjust in file "codegen/compile.ml", line 6612, characters 6-82
Called from Codegen__Compile.compile_exp_as in file "codegen/compile.ml", line 9254, characters 14-46
Called from Codegen__Compile.compile_prim_invocation in file "codegen/compile.ml", line 8245, characters 9-60
Called from Codegen__Compile.compile_exp in file "codegen/compile.ml", line 9120, characters 4-54
Called from Codegen__Compile.compile_exp_as in file "codegen/compile.ml", line 9253, characters 24-44
Called from Codegen__Compile.FuncDec.compile_const_message.(fun) in file "codegen/compile.ml", line 6938, characters 6-21
Called from Codegen__Compile.Func.of_body in file "codegen/compile.ml", line 764, characters 6-18
Called from Codegen__Compile.FuncDec.closed.(fun) in file "codegen/compile.ml", line 6948, characters 13-80
Called from Codegen__Compile.compile_dec.(fun) in file "codegen/compile.ml", line 9523, characters 33-44
Called from Codegen__Compile.compile_dec.(fun) in file "codegen/compile.ml", line 9513, characters 29-41
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 9574, characters 44-62
Called from Codegen__Compile.compile_decs_public.(fun) in file "codegen/compile.ml", line 9577, characters 39-61
Called from Codegen__Compile.main_actor.(fun) in file "codegen/compile.ml", line 9813, characters 4-21
Called from Codegen__Compile.Func.of_body in file "codegen/compile.ml", line 764, characters 6-18
Called from CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 31, characters 17-27
Re-raised at CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 36, characters 4-11
Called from Lib.AllocOnUse.use in file "lib/lib.ml", line 527, characters 13-28
Called from Codegen__Compile.E.built_in in file "codegen/compile.ml" (inlined), line 452, characters 4-49
Called from Codegen__Compile.IC.export_init.(fun) in file "codegen/compile.ml", line 3842, characters 20-43
Called from Codegen__Compile.Func.of_body in file "codegen/compile.ml", line 764, characters 6-18
Called from Codegen__Compile.IC.export_init in file "codegen/compile.ml", line 3839, characters 18-228
Called from Codegen__Compile.compile in file "codegen/compile.ml", line 9928, characters 6-24
Called from Pipeline.compile_files in file "pipeline/pipeline.ml", line 690, characters 19-56
Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30
Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30
Called from Dune__exe__Moc.process_files in file "exes/moc.ml", line 203, characters 49-94
Called from Dune__exe__Moc in file "exes/moc.ml", line 298, characters 4-23


real    0m18.818s
user    0m18.562s
sys     0m0.412s
@ggreif ggreif changed the title Fatal error: exception "Assert_failure mo_types/typ_hash.ml:123:27" Type checker doesn't reject parametrised shared functions Oct 25, 2022
@ggreif
Copy link
Contributor

ggreif commented Oct 25, 2022

There is no good story for polymorphic shared endpoints atm. Sorry for that :-(
Also Candid doesn't have them.

@crusso
Copy link
Contributor

crusso commented Oct 25, 2022

But we should not be crashing, for sure.

@crusso
Copy link
Contributor

crusso commented Oct 25, 2022

Possible repro:

actor {

   type Bad<T> =  Nat;

   public query func foo<T>() : async Bad<T> { loop {} };

}

@ggreif
Copy link
Contributor

ggreif commented Oct 25, 2022

@borovan are you sure your example doesn't compile? Can you provide a self-sufficient example like above?

this works for me at least:

actor {

    type Bad<T> = { thing : Nat };

    public shared ({caller}) func bar<T>(inp : Int) : async Bad<T> { return { thing = 42 } };

}

@borovan
Copy link
Contributor Author

borovan commented Oct 25, 2022

shared ({ caller = owner }) actor class Service(playerPrincipal : Principal) = this {

  type GenericType<T> = {
    thing : Nat;
  };

  // test
  public shared ({ caller }) func asplode<T>() : async GenericType<T> {
    return {
      thing = 1;
    };
  };

};

this crashes for me

@borovan
Copy link
Contributor Author

borovan commented Oct 25, 2022

shared ({ caller = owner }) actor class Service() = this {

  type GenericType<T> = {
    thing : Nat;
  };

  // test
  public shared ({ caller }) func asplode<T>() : async GenericType<T> {
    return {
      thing = 1;
    };
  };

};

``` same 

@borovan
Copy link
Contributor Author

borovan commented Oct 25, 2022

while you're here, do you have any code that uses typ-params? I was trying to figure out what it does as part of the new subtype system? :)

@ggreif
Copy link
Contributor

ggreif commented Oct 25, 2022

shared ({ caller = owner }) actor class Service(playerPrincipal : Principal) = this {

  type GenericType<T> = {
    thing : Nat;
  };

  // test
  public shared ({ caller }) func asplode<T>() : async GenericType<T> {
    return {
      thing = 1;
    };
  };

};

this crashes for me

Totally works for me, using

$ moc --version
Motoko compiler (source 0.7.1-3-gbe6229357-dirty)

--idl also works:

$ cat shared-poly.did
type Service = 
 service {
   asplode: () -> (GenericType);
 };
type GenericType = record {thing: nat;};
service : (principal) -> Service

@borovan
Copy link
Contributor Author

borovan commented Oct 25, 2022

~/.cache/dfinity/versions/0.12.0-beta.3/moc --version
Motoko compiler 0.7.1 (source i0kp307y-xrdvn6np-f7lvsab8-l4qgrg4a)

hmm i dunno then... its not like i need it to work at all

@crusso
Copy link
Contributor

crusso commented Oct 26, 2022

I can't reproduce it either (on linux)

@crusso
Copy link
Contributor

crusso commented Oct 26, 2022

Ok, I think I can reproduce it with an empty main actor that imports the class above.

@crusso
Copy link
Contributor

crusso commented Oct 26, 2022

#3522 contains the repro (not a fix)

@crusso
Copy link
Contributor

crusso commented Oct 26, 2022

#3522 now contains a fix

@crusso
Copy link
Contributor

crusso commented Oct 26, 2022

@borovan thanks for reporting this!

crusso added a commit that referenced this issue Oct 26, 2022
…3519) (#3522)

* repro for issue 3519

* Update test/run-drun/issue-3519.mo

* Apply suggestions from code review

* fix for issue #3519

* Apply suggestions from code review

* adapt test (making public function private to allow generics)

* revise test output

* adjust comments
@ggreif
Copy link
Contributor

ggreif commented Oct 28, 2022

Resolved via #3522 and #3525.

@ggreif ggreif closed this as completed Oct 28, 2022
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

3 participants