@@ -4070,7 +4070,7 @@ and infer_dec env dec : T.typ =
40704070 error env dec.at " M0227" " mixins can only be included in an actor context" ;
40714071 match T.Env. find_opt i.it env.mixins with
40724072 | None -> error env i.at " M0226" " unknown mixin %s" i.it
4073- | Some ( _ , pat , _ , _ ) -> check_exp env pat .note arg
4073+ | Some mix -> check_exp env mix. Scope. arg .note arg
40744074 end ;
40754075 T. unit
40764076 | ExpD exp -> infer_exp env exp
@@ -4263,9 +4263,9 @@ and gather_dec env scope dec : Scope.t =
42634263 }
42644264 | LetD (pat , exp , _ ) -> (match is_mixin_import env exp.it with
42654265 | None -> gather_pat env scope pat
4266- | Some ( imports , args , t , decs ) ->
4266+ | Some mix ->
42674267 match pat.it with
4268- | VarP id -> Scope. adjoin scope (Scope. mixin id.it (imports, args, t, decs) )
4268+ | VarP id -> Scope. adjoin scope (Scope. mixin id.it mix )
42694269 | _ -> error env pat.at " M0229" " mixins may only be imported by binding to a name"
42704270 )
42714271 | VarD (id , _ ) -> Scope. adjoin_val_env scope (gather_id env scope.Scope. val_env id Scope. Declaration )
@@ -4307,9 +4307,9 @@ and gather_dec env scope dec : Scope.t =
43074307 | IncludeD (i , _ , _ ) -> begin
43084308 match T.Env. find_opt i.it env.mixins with
43094309 | None -> error env i.at " M0226" " unknown mixin %s" i.it
4310- | Some ( imports , pat , decs , t ) ->
4310+ | Some mix ->
43114311 let open Scope in
4312- let (_, fields) = T. as_obj t in
4312+ let (_, fields) = T. as_obj mix.typ in
43134313 let add_field acc = function
43144314 | T. { lab; typ = T. Typ t ; _ } ->
43154315 if T.Env. mem lab acc.typ_env then error_duplicate env " type " { it = lab; at = i.at; note = () };
@@ -4373,12 +4373,13 @@ and infer_dec_typdecs env dec : Scope.t =
43734373 | IncludeD (i , _ , n ) -> begin
43744374 match T.Env. find_opt i.it env.mixins with
43754375 | None -> error env i.at " M0226" " unknown mixin %s" i.it
4376- | Some (imports , pat , decs , t ) ->
4377- n := Some ({ imports; pat; decs });
4378- let (_, fields) = T. as_obj t in
4376+ | Some mix ->
4377+ let open Scope in
4378+ n := Some ({ imports = mix.imports; pat = mix.arg; decs = mix.decs });
4379+ let (_, fields) = T. as_obj mix.typ in
43794380 let scope = scope_of_object env fields in
43804381 (* Mark all included idents as used to avoid spurious warnings *)
4381- T.Env. iter (fun i _ -> use_identifier env i) scope.Scope. val_env;
4382+ T.Env. iter (fun i _ -> use_identifier env i) scope.val_env;
43824383 scope
43834384 end
43844385 (* TODO: generalize beyond let <id> = <obje> *)
@@ -4401,9 +4402,9 @@ and infer_dec_typdecs env dec : Scope.t =
44014402 (* TODO: generalize beyond let <id> = <valpath> *)
44024403 | LetD ({it = VarP id ; _} , exp , _ ) ->
44034404 begin match is_mixin_import env exp.it with
4404- | Some ( imports , args , t , decs ) ->
4405+ | Some mix ->
44054406 (* Format.printf "Adding mixin %s at %a\n" id.it display_typ t; *)
4406- Scope. mixin id.it (imports, args, t, decs)
4407+ Scope. mixin id.it mix
44074408 | None ->
44084409 (match infer_val_path env exp with
44094410 | None -> Scope. empty
@@ -4648,8 +4649,8 @@ let check_lib scope pkg_opt lib : Scope.t Diag.result =
46484649 (" system" , obj Module [id.it, install_typ (List. map (close cs) ts1) class_typ])
46494650 ]) in
46504651 Scope. lib lib.note.filename typ
4651- | MixinU (pat , decs ) ->
4652- Scope. mixin lib.note.filename ( imports, pat, decs, typ)
4652+ | MixinU (arg , decs ) ->
4653+ Scope. mixin lib.note.filename Scope. { imports; arg; decs; typ }
46534654 | ActorU _ ->
46544655 error env cub.at " M0144" " bad import: expected a module or actor class but found an actor"
46554656 | ProgU _ ->
0 commit comments