|
|
@@ -392,12 +392,12 @@ let build_enum_abstract ctx c a fields p =
|
|
|
| VUnknown ->
|
|
|
()
|
|
|
| VPublic(access,p2) | VPrivate(access,p2) ->
|
|
|
- display_error ctx (Printf.sprintf "Conflicting access modifier %s" (Ast.s_access access)) p1;
|
|
|
- display_error ctx "Conflicts with this" p2;
|
|
|
+ display_error ctx.com (Printf.sprintf "Conflicting access modifier %s" (Ast.s_access access)) p1;
|
|
|
+ display_error ctx.com "Conflicts with this" p2;
|
|
|
in
|
|
|
let rec loop visibility acc = match acc with
|
|
|
| (AExtern,p) :: acc ->
|
|
|
- display_error ctx "extern modifier is not allowed on enum abstract fields" p;
|
|
|
+ display_error ctx.com "extern modifier is not allowed on enum abstract fields" p;
|
|
|
loop visibility acc
|
|
|
| (APrivate,p) as access :: acc ->
|
|
|
check_visibility_conflict visibility p;
|
|
|
@@ -551,7 +551,7 @@ let create_typer_context_for_class ctx cctx p =
|
|
|
incr stats.s_classes_built;
|
|
|
let c = cctx.tclass in
|
|
|
if cctx.is_lib && not (has_class_flag c CExtern) then ctx.com.error "@:libType can only be used in extern classes" c.cl_pos;
|
|
|
- if Meta.has Meta.Macro c.cl_meta then display_error ctx "Macro classes are no longer allowed in haxe 3" c.cl_pos;
|
|
|
+ if Meta.has Meta.Macro c.cl_meta then display_error ctx.com "Macro classes are no longer allowed in haxe 3" c.cl_pos;
|
|
|
let ctx = {
|
|
|
ctx with
|
|
|
curclass = c;
|
|
|
@@ -644,14 +644,14 @@ let create_typer_context_for_field ctx cctx fctx cff =
|
|
|
let c = cctx.tclass in
|
|
|
if (fctx.is_abstract && not (has_meta Meta.LibType c.cl_meta)) then begin
|
|
|
if fctx.is_static then
|
|
|
- display_error ctx "Static methods may not be abstract" (pos cff.cff_name)
|
|
|
+ display_error ctx.com "Static methods may not be abstract" (pos cff.cff_name)
|
|
|
else if fctx.is_final then
|
|
|
- display_error ctx "Abstract methods may not be final" (pos cff.cff_name)
|
|
|
+ display_error ctx.com "Abstract methods may not be final" (pos cff.cff_name)
|
|
|
else if fctx.is_inline then
|
|
|
- display_error ctx "Abstract methods may not be inline" (pos cff.cff_name)
|
|
|
+ display_error ctx.com "Abstract methods may not be inline" (pos cff.cff_name)
|
|
|
else if not (has_class_flag c CAbstract) then begin
|
|
|
- display_error ctx "This class should be declared abstract because it has at least one abstract field" c.cl_name_pos;
|
|
|
- display_error ctx "First abstract field was here" (pos cff.cff_name);
|
|
|
+ display_error ctx.com "This class should be declared abstract because it has at least one abstract field" c.cl_name_pos;
|
|
|
+ display_error ctx.com "First abstract field was here" (pos cff.cff_name);
|
|
|
add_class_flag c CAbstract;
|
|
|
end;
|
|
|
end;
|
|
|
@@ -826,14 +826,14 @@ module TypeBinding = struct
|
|
|
| Some (csup,_) ->
|
|
|
(* this can happen on -net-lib generated classes if a combination of explicit interfaces and variables with the same name happens *)
|
|
|
if not ((has_class_flag csup CInterface) && Meta.has Meta.CsNative c.cl_meta) then
|
|
|
- display_error ctx ("Redefinition of variable " ^ cf.cf_name ^ " in subclass is not allowed. Previously declared at " ^ (s_type_path csup.cl_path) ) cf.cf_name_pos
|
|
|
+ display_error ctx.com ("Redefinition of variable " ^ cf.cf_name ^ " in subclass is not allowed. Previously declared at " ^ (s_type_path csup.cl_path) ) cf.cf_name_pos
|
|
|
end
|
|
|
|
|
|
let bind_var_expression ctx cctx fctx cf e =
|
|
|
let c = cctx.tclass in
|
|
|
let t = cf.cf_type in
|
|
|
let p = cf.cf_pos in
|
|
|
- if (has_class_flag c CInterface) then display_error ctx "Default values on interfaces are not allowed" (pos e);
|
|
|
+ if (has_class_flag c CInterface) then display_error ctx.com "Default values on interfaces are not allowed" (pos e);
|
|
|
cf.cf_meta <- ((Meta.Value,[e],null_pos) :: cf.cf_meta);
|
|
|
let check_cast e =
|
|
|
(* insert cast to keep explicit field type (issue #1901) *)
|
|
|
@@ -861,28 +861,28 @@ module TypeBinding = struct
|
|
|
let require_constant_expression e msg =
|
|
|
match Optimizer.make_constant_expression ctx (maybe_run_analyzer e) with
|
|
|
| Some e -> e
|
|
|
- | None -> display_error ctx msg p; e
|
|
|
+ | None -> display_error ctx.com msg p; e
|
|
|
in
|
|
|
let e = (match cf.cf_kind with
|
|
|
| Var v when (has_class_flag c CExtern) || fctx.is_extern ->
|
|
|
if not fctx.is_static then begin
|
|
|
- display_error ctx "Extern non-static variables may not be initialized" p;
|
|
|
+ display_error ctx.com "Extern non-static variables may not be initialized" p;
|
|
|
e
|
|
|
end else if not fctx.is_inline then begin
|
|
|
- display_error ctx "Extern non-inline variables may not be initialized" p;
|
|
|
+ display_error ctx.com "Extern non-inline variables may not be initialized" p;
|
|
|
e
|
|
|
end else require_constant_expression e "Extern variable initialization must be a constant value"
|
|
|
| Var v when not (is_physical_field cf) ->
|
|
|
(* disallow initialization of non-physical fields (issue #1958) *)
|
|
|
- display_error ctx "This field cannot be initialized because it is not a real variable" p; e
|
|
|
+ display_error ctx.com "This field cannot be initialized because it is not a real variable" p; e
|
|
|
| Var v when not fctx.is_static ->
|
|
|
let e = begin
|
|
|
let rec check_this e = match e.eexpr with
|
|
|
| TConst TThis ->
|
|
|
- display_error ctx "Cannot access this or other member field in variable initialization" e.epos;
|
|
|
+ display_error ctx.com "Cannot access this or other member field in variable initialization" e.epos;
|
|
|
raise Exit
|
|
|
| TLocal v when (match ctx.vthis with Some v2 -> v == v2 | None -> false) ->
|
|
|
- display_error ctx "Cannot access this or other member field in variable initialization" e.epos;
|
|
|
+ display_error ctx.com "Cannot access this or other member field in variable initialization" e.epos;
|
|
|
raise Exit
|
|
|
| _ ->
|
|
|
Type.iter check_this e
|
|
|
@@ -1192,13 +1192,13 @@ let type_opt (ctx,cctx,fctx) p t =
|
|
|
in
|
|
|
match t with
|
|
|
| None when is_truly_extern || (has_class_flag c CInterface) ->
|
|
|
- display_error ctx "Type required for extern classes and interfaces" p;
|
|
|
+ display_error ctx.com "Type required for extern classes and interfaces" p;
|
|
|
t_dynamic
|
|
|
| None when cctx.is_core_api ->
|
|
|
- display_error ctx "Type required for core api classes" p;
|
|
|
+ display_error ctx.com "Type required for core api classes" p;
|
|
|
t_dynamic
|
|
|
| None when fctx.is_abstract ->
|
|
|
- display_error ctx "Type required for abstract functions" p;
|
|
|
+ display_error ctx.com "Type required for abstract functions" p;
|
|
|
t_dynamic
|
|
|
| _ ->
|
|
|
Typeload.load_type_hint ctx p t
|
|
|
@@ -1269,7 +1269,7 @@ let create_method (ctx,cctx,fctx) c f fd p =
|
|
|
end;
|
|
|
let parent = (if not fctx.is_static then get_parent c name else None) in
|
|
|
let dynamic = List.mem_assoc ADynamic f.cff_access || (match parent with Some { cf_kind = Method MethDynamic } -> true | _ -> false) in
|
|
|
- if fctx.is_abstract && dynamic then display_error ctx "Abstract methods may not be dynamic" p;
|
|
|
+ if fctx.is_abstract && dynamic then display_error ctx.com "Abstract methods may not be dynamic" p;
|
|
|
if fctx.is_inline && dynamic then typing_error (fst f.cff_name ^ ": 'inline' is not allowed on 'dynamic' functions") p;
|
|
|
let is_override = Option.is_some fctx.override in
|
|
|
if (is_override && fctx.is_static) then typing_error (fst f.cff_name ^ ": 'override' is not allowed on 'static' functions") p;
|
|
|
@@ -1345,7 +1345,7 @@ let create_method (ctx,cctx,fctx) c f fd p =
|
|
|
try List.assoc AAbstract f.cff_access
|
|
|
with Not_found -> p
|
|
|
in
|
|
|
- display_error ctx "Constructors cannot be abstract" p
|
|
|
+ display_error ctx.com "Constructors cannot be abstract" p
|
|
|
end;
|
|
|
add_class_field_flag cf CfAbstract;
|
|
|
end;
|
|
|
@@ -1355,10 +1355,10 @@ let create_method (ctx,cctx,fctx) c f fd p =
|
|
|
| Some p ->
|
|
|
begin match ctx.com.platform with
|
|
|
| Java ->
|
|
|
- if not (has_class_flag ctx.curclass CExtern) || not (has_class_flag c CInterface) then display_error ctx "The default modifier is only allowed on extern interfaces" p;
|
|
|
+ if not (has_class_flag ctx.curclass CExtern) || not (has_class_flag c CInterface) then display_error ctx.com "The default modifier is only allowed on extern interfaces" p;
|
|
|
add_class_field_flag cf CfDefault;
|
|
|
| _ ->
|
|
|
- display_error ctx "The default modifier is only supported on the Java target" p
|
|
|
+ display_error ctx.com "The default modifier is only supported on the Java target" p
|
|
|
end;
|
|
|
| None ->
|
|
|
()
|
|
|
@@ -1368,11 +1368,11 @@ let create_method (ctx,cctx,fctx) c f fd p =
|
|
|
if ctx.com.config.pf_overload then
|
|
|
add_class_field_flag cf CfOverload
|
|
|
else if fctx.field_kind = FKConstructor then
|
|
|
- display_error ctx "Constructors cannot be overloaded on this target" p
|
|
|
+ display_error ctx.com "Constructors cannot be overloaded on this target" p
|
|
|
else begin
|
|
|
add_class_field_flag cf CfOverload;
|
|
|
if not (has_class_flag c CExtern || fctx.is_extern) then
|
|
|
- display_error ctx "Only extern functions may be overloaded on this target" p
|
|
|
+ display_error ctx.com "Only extern functions may be overloaded on this target" p
|
|
|
end
|
|
|
| None ->
|
|
|
()
|
|
|
@@ -1405,7 +1405,7 @@ let create_method (ctx,cctx,fctx) c f fd p =
|
|
|
end else
|
|
|
delay ctx PTypeField (fun () -> args#verify_extern);
|
|
|
if fd.f_expr <> None then begin
|
|
|
- if fctx.is_abstract then display_error ctx "Abstract methods may not have an expression" p
|
|
|
+ if fctx.is_abstract then display_error ctx.com "Abstract methods may not have an expression" p
|
|
|
else if not (fctx.is_inline || fctx.is_macro) then warning ctx WExternInit "Extern non-inline function may not have an expression" p;
|
|
|
end;
|
|
|
end;
|
|
|
@@ -1465,12 +1465,12 @@ let create_property (ctx,cctx,fctx) c f (get,set,t,eo) p =
|
|
|
try
|
|
|
(match f2.cf_kind with
|
|
|
| Method MethMacro ->
|
|
|
- display_error ctx (f2.cf_name ^ ": Macro methods cannot be used as property accessor") p;
|
|
|
- display_error ctx (compl_msg (f2.cf_name ^ ": Accessor method is here")) f2.cf_pos;
|
|
|
+ display_error ctx.com (f2.cf_name ^ ": Macro methods cannot be used as property accessor") p;
|
|
|
+ display_error ctx.com (compl_msg (f2.cf_name ^ ": Accessor method is here")) f2.cf_pos;
|
|
|
| _ -> ());
|
|
|
unify_raise t2 t f2.cf_pos;
|
|
|
if (fctx.is_abstract_member && not (has_class_field_flag f2 CfImpl)) || (has_class_field_flag f2 CfImpl && not (fctx.is_abstract_member)) then
|
|
|
- display_error ctx "Mixing abstract implementation and static properties/accessors is not allowed" f2.cf_pos;
|
|
|
+ display_error ctx.com "Mixing abstract implementation and static properties/accessors is not allowed" f2.cf_pos;
|
|
|
with Error (Unify l,p) ->
|
|
|
raise (Error (Stack (Custom ("In method " ^ m ^ " required by property " ^ name),Unify l),p))
|
|
|
)
|
|
|
@@ -1501,9 +1501,9 @@ let create_property (ctx,cctx,fctx) c f (get,set,t,eo) p =
|
|
|
end else if not (has_class_flag c CExtern) then begin
|
|
|
try
|
|
|
let _, _, f2 = (if not fctx.is_static then let f = PMap.find m c.cl_statics in None, f.cf_type, f else class_field c (extract_param_types c.cl_params) m) in
|
|
|
- display_error ctx (Printf.sprintf "Method %s is no valid accessor for %s because it is %sstatic" m (name) (if fctx.is_static then "not " else "")) f2.cf_pos
|
|
|
+ display_error ctx.com (Printf.sprintf "Method %s is no valid accessor for %s because it is %sstatic" m (name) (if fctx.is_static then "not " else "")) f2.cf_pos
|
|
|
with Not_found ->
|
|
|
- display_error ctx ("Method " ^ m ^ " required by property " ^ name ^ " is missing") p
|
|
|
+ display_error ctx.com ("Method " ^ m ^ " required by property " ^ name ^ " is missing") p
|
|
|
end
|
|
|
in
|
|
|
let display_accessor m p =
|
|
|
@@ -1525,7 +1525,7 @@ let create_property (ctx,cctx,fctx) c f (get,set,t,eo) p =
|
|
|
if not cctx.is_lib then delay_check (fun() -> check_method get t_get true);
|
|
|
AccCall
|
|
|
| _,pget ->
|
|
|
- display_error ctx (name ^ ": Custom property accessor is no longer supported, please use `get`") pget;
|
|
|
+ display_error ctx.com (name ^ ": Custom property accessor is no longer supported, please use `get`") pget;
|
|
|
AccCall
|
|
|
) in
|
|
|
let set = (match set with
|
|
|
@@ -1544,7 +1544,7 @@ let create_property (ctx,cctx,fctx) c f (get,set,t,eo) p =
|
|
|
if not cctx.is_lib then delay_check (fun() -> check_method set t_set false);
|
|
|
AccCall
|
|
|
| _,pset ->
|
|
|
- display_error ctx (name ^ ": Custom property accessor is no longer supported, please use `set`") pset;
|
|
|
+ display_error ctx.com (name ^ ": Custom property accessor is no longer supported, please use `set`") pset;
|
|
|
AccCall
|
|
|
) in
|
|
|
if (set = AccNever && get = AccNever) then typing_error (name ^ ": Unsupported property combination") p;
|
|
|
@@ -1580,8 +1580,8 @@ let init_field (ctx,cctx,fctx) f =
|
|
|
match (fst acc, f.cff_kind) with
|
|
|
| APublic, _ | APrivate, _ | AStatic, _ | AFinal, _ | AExtern, _ -> ()
|
|
|
| ADynamic, FFun _ | AOverride, FFun _ | AMacro, FFun _ | AInline, FFun _ | AInline, FVar _ | AAbstract, FFun _ | AOverload, FFun _ -> ()
|
|
|
- | _, FVar _ -> display_error ctx ("Invalid accessor '" ^ Ast.s_placed_access acc ^ "' for variable " ^ name) (snd acc)
|
|
|
- | _, FProp _ -> display_error ctx ("Invalid accessor '" ^ Ast.s_placed_access acc ^ "' for property " ^ name) (snd acc)
|
|
|
+ | _, FVar _ -> display_error ctx.com ("Invalid accessor '" ^ Ast.s_placed_access acc ^ "' for variable " ^ name) (snd acc)
|
|
|
+ | _, FProp _ -> display_error ctx.com ("Invalid accessor '" ^ Ast.s_placed_access acc ^ "' for property " ^ name) (snd acc)
|
|
|
) f.cff_access;
|
|
|
begin match fctx.override with
|
|
|
| Some _ ->
|
|
|
@@ -1623,8 +1623,8 @@ let check_overload ctx f fs =
|
|
|
Overloads.same_overload_args f.cf_type f2.cf_type f f2
|
|
|
) fs
|
|
|
in
|
|
|
- display_error ctx ("Another overloaded field of same signature was already declared : " ^ f.cf_name) f.cf_pos;
|
|
|
- display_error ctx (compl_msg "The second field is declared here") f2.cf_pos;
|
|
|
+ display_error ctx.com ("Another overloaded field of same signature was already declared : " ^ f.cf_name) f.cf_pos;
|
|
|
+ display_error ctx.com (compl_msg "The second field is declared here") f2.cf_pos;
|
|
|
false
|
|
|
with Not_found -> try
|
|
|
(* OVERLOADTODO: generalize this and respect whether or not we actually generate the functions *)
|
|
|
@@ -1636,12 +1636,12 @@ let check_overload ctx f fs =
|
|
|
Overloads.same_overload_args ~get_vmtype f.cf_type f2.cf_type f f2
|
|
|
) fs
|
|
|
in
|
|
|
- display_error ctx (
|
|
|
+ display_error ctx.com (
|
|
|
"Another overloaded field of similar signature was already declared : " ^
|
|
|
f.cf_name ^
|
|
|
"\nThe signatures are different in Haxe, but not in the target language"
|
|
|
) f.cf_pos;
|
|
|
- display_error ctx (compl_msg "The second field is declared here") f2.cf_pos;
|
|
|
+ display_error ctx.com (compl_msg "The second field is declared here") f2.cf_pos;
|
|
|
false
|
|
|
with Not_found ->
|
|
|
true
|
|
|
@@ -1718,7 +1718,7 @@ let init_class ctx c p context_init herits fields =
|
|
|
let cf = init_field (ctx,cctx,fctx) f in
|
|
|
if fctx.field_kind = FKInit then begin
|
|
|
if !has_init then
|
|
|
- display_error ctx ("Duplicate class field declaration : " ^ (s_type_path c.cl_path) ^ "." ^ cf.cf_name) cf.cf_name_pos
|
|
|
+ display_error ctx.com ("Duplicate class field declaration : " ^ (s_type_path c.cl_path) ^ "." ^ cf.cf_name) cf.cf_name_pos
|
|
|
else
|
|
|
has_init := true
|
|
|
end;
|
|
|
@@ -1749,9 +1749,9 @@ let init_class ctx c p context_init herits fields =
|
|
|
if has_class_field_flag cf CfOverload && has_class_field_flag ctor CfOverload then
|
|
|
ctor.cf_overloads <- cf :: ctor.cf_overloads
|
|
|
else
|
|
|
- display_error ctx ("If using overloaded constructors, all constructors must be declared with 'overload'") (if has_class_field_flag cf CfOverload then ctor.cf_pos else cf.cf_pos)
|
|
|
+ display_error ctx.com ("If using overloaded constructors, all constructors must be declared with 'overload'") (if has_class_field_flag cf CfOverload then ctor.cf_pos else cf.cf_pos)
|
|
|
| Some ctor ->
|
|
|
- display_error ctx "Duplicate constructor" p
|
|
|
+ display_error ctx.com "Duplicate constructor" p
|
|
|
end
|
|
|
| FKInit ->
|
|
|
()
|
|
|
@@ -1764,8 +1764,8 @@ let init_class ctx c p context_init herits fields =
|
|
|
if PMap.mem cf.cf_name (if fctx.is_static then c.cl_statics else c.cl_fields) then
|
|
|
if has_class_field_flag cf CfOverload && not (is_var cf) then
|
|
|
let mainf = PMap.find cf.cf_name (if fctx.is_static then c.cl_statics else c.cl_fields) in
|
|
|
- if is_var mainf then display_error ctx "Cannot declare a variable with same name as a method" mainf.cf_pos;
|
|
|
- (if not (has_class_field_flag mainf CfOverload) then display_error ctx ("Overloaded methods must have 'overload' accessor") mainf.cf_pos);
|
|
|
+ if is_var mainf then display_error ctx.com "Cannot declare a variable with same name as a method" mainf.cf_pos;
|
|
|
+ (if not (has_class_field_flag mainf CfOverload) then display_error ctx.com ("Overloaded methods must have 'overload' accessor") mainf.cf_pos);
|
|
|
mainf.cf_overloads <- cf :: cf.cf_overloads @ mainf.cf_overloads
|
|
|
else
|
|
|
let type_kind,path = match c.cl_kind with
|
|
|
@@ -1773,12 +1773,12 @@ let init_class ctx c p context_init herits fields =
|
|
|
| KModuleFields m -> "module",m.m_path
|
|
|
| _ -> "class",c.cl_path
|
|
|
in
|
|
|
- display_error ctx ("Duplicate " ^ type_kind ^ " field declaration : " ^ s_type_path path ^ "." ^ cf.cf_name) cf.cf_name_pos
|
|
|
+ display_error ctx.com ("Duplicate " ^ type_kind ^ " field declaration : " ^ s_type_path path ^ "." ^ cf.cf_name) cf.cf_name_pos
|
|
|
else
|
|
|
if fctx.do_add then TClass.add_field c cf
|
|
|
end
|
|
|
with Error (Custom str,p2) when p = p2 ->
|
|
|
- display_error ctx str p
|
|
|
+ display_error ctx.com str p
|
|
|
) fields;
|
|
|
(match cctx.abstract with
|
|
|
| Some a ->
|
|
|
@@ -1825,9 +1825,9 @@ let init_class ctx c p context_init herits fields =
|
|
|
in
|
|
|
if has_struct_init then
|
|
|
if (has_class_flag c CInterface) then
|
|
|
- display_error ctx "@:structInit is not allowed on interfaces" struct_init_pos
|
|
|
+ display_error ctx.com "@:structInit is not allowed on interfaces" struct_init_pos
|
|
|
else if (has_class_flag c CAbstract) then
|
|
|
- display_error ctx "@:structInit is not allowed on abstract classes" struct_init_pos
|
|
|
+ display_error ctx.com "@:structInit is not allowed on abstract classes" struct_init_pos
|
|
|
else
|
|
|
ensure_struct_init_constructor ctx c fields p;
|
|
|
begin match cctx.uninitialized_final with
|
|
|
@@ -1842,8 +1842,8 @@ let init_class ctx c p context_init herits fields =
|
|
|
let display = ctx.com.display_information in
|
|
|
display.module_diagnostics <- MissingFields diag :: display.module_diagnostics
|
|
|
end else begin
|
|
|
- display_error ctx "This class has uninitialized final vars, which requires a constructor" p;
|
|
|
- display_error ctx "Example of an uninitialized final var" cf.cf_name_pos;
|
|
|
+ display_error ctx.com "This class has uninitialized final vars, which requires a constructor" p;
|
|
|
+ display_error ctx.com "Example of an uninitialized final var" cf.cf_name_pos;
|
|
|
end
|
|
|
| _ ->
|
|
|
()
|