this needs more investigation, because we might want still show something but with correct position and phrasing, when there's an actual call from a macro
@@ -734,6 +734,12 @@ let has_constructor c =
true
with Not_found -> false
+let is_module_statics_class c =
+ match c.cl_kind with KModuleStatics _ -> true | _ -> false
+
+let is_pos_outside_class c p =
+ p.pfile <> c.cl_pos.pfile || p.pmax < c.cl_pos.pmin || p.pmin > c.cl_pos.pmax
let resolve_typedef t =
match t with
| TClassDecl _ | TEnumDecl _ | TAbstractDecl _ -> t
@@ -513,7 +513,8 @@ let create_class_context ctx c context_init p =
on_error = (fun ctx msg ep ->
ctx.com.error msg ep;
(* macros expressions might reference other code, let's recall which class we are actually compiling *)
- if !locate_macro_error && (ep.pfile <> c.cl_pos.pfile || ep.pmax < c.cl_pos.pmin || ep.pmin > c.cl_pos.pmax) then ctx.com.error "Defined in this class" c.cl_pos
+ let open TFunctions in
+ if !locate_macro_error && (is_pos_outside_class c ep) && not (is_module_statics_class c) then ctx.com.error "Defined in this class" c.cl_pos
);
} in
(* a lib type will skip most checks *)