Skip to content

Commit

Permalink
Merge branch 'HaxeFoundation:development' into feature/atomics
Browse files Browse the repository at this point in the history
  • Loading branch information
Apprentice-Alchemist authored May 10, 2022
2 parents 88341ec + 1f8b854 commit 0dca14a
Show file tree
Hide file tree
Showing 124 changed files with 1,276 additions and 500 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,4 @@ tests/server/test.js.map
*.merlin
lib.sexp
src/compiler/version.ml
tests/party
2 changes: 1 addition & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ test-environment-cs:

test-environment-hl:
FROM +test-environment
DO +INSTALL_PACKAGES --PACKAGES="cmake ninja-build libturbojpeg-dev libpng-dev zlib1g-dev libvorbis-dev"
DO +INSTALL_PACKAGES --PACKAGES="cmake ninja-build libturbojpeg-dev libpng-dev zlib1g-dev libvorbis-dev libsqlite3-dev"
SAVE IMAGE --cache-hint

test-environment-lua:
Expand Down
2 changes: 1 addition & 1 deletion extra/haxelib_src
Submodule haxelib_src updated 46 files
+1 −1 haxelib.json
+ run.n
+81 −147 src/haxelib/Data.hx
+78 −0 src/haxelib/MetaData.hx
+1 −1 src/haxelib/SiteApi.hx
+9 −9 src/haxelib/Util.hx
+6 −2 src/haxelib/Validator.hx
+87 −0 src/haxelib/VersionData.hx
+7 −6 src/haxelib/api/Connection.hx
+9 −5 src/haxelib/api/GlobalScope.hx
+42 −50 src/haxelib/api/Installer.hx
+10 −50 src/haxelib/api/LibFlagData.hx
+5 −24 src/haxelib/api/LibraryData.hx
+12 −9 src/haxelib/api/Repository.hx
+2 −1 src/haxelib/api/Scope.hx
+10 −2 src/haxelib/api/ScriptRunner.hx
+1 −21 src/haxelib/api/Vcs.hx
+46 −71 src/haxelib/client/Args.hx
+51 −30 src/haxelib/client/Main.hx
+106 −13 src/haxelib/client/Util.hx
+2 −1 src/haxelib/server/Repo.hx
+1 −0 src/website/api/ProjectApi.hx
+1 −0 test/HaxelibTests.hx
+9 −0 test/libraries/libFooGitDep/foo/Foo.hx
+13 −0 test/libraries/libFooGitDep/haxelib.json
+9 −0 test/libraries/libFooHgDep/foo/Foo.hx
+13 −0 test/libraries/libFooHgDep/haxelib.json
+3 −0 test/libraries/libInvalidLicense/Main.hx
+10 −0 test/libraries/libInvalidLicense/haxelib.json
+13 −6 test/tests/TestArgs.hx
+67 −59 test/tests/TestData.hx
+1 −1 test/tests/TestGit.hx
+1 −1 test/tests/TestGlobalScope.hx
+2 −2 test/tests/TestInstaller.hx
+7 −0 test/tests/TestRepoReformatter.hx
+1 −1 test/tests/TestScope.hx
+1 −0 test/tests/TestVcs.hx
+68 −0 test/tests/TestVersionData.hx
+8 −0 test/tests/integration/TestFixRepo.hx
+57 −0 test/tests/integration/TestInstall.hx
+28 −0 test/tests/integration/TestPath.hx
+17 −8 test/tests/integration/TestSet.hx
+63 −0 test/tests/integration/TestSubmit.hx
+41 −51 test/tests/integration/TestUpdate.hx
+16 −0 test/tests/util/MockRepositories.hx
+9 −8 www/documentation-files/using-haxelib.md
3 changes: 2 additions & 1 deletion libs/swflib/as3hlparse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ let flatten t =
Array.iter (browse_field ctx) s.hls_fields;
browse_method ctx s.hls_method;
) t;
let classes = List.sort (fun c1 c2 -> c1.hlc_index - c2.hlc_index) (List.rev !classes) in
let methods = List.sort (fun m1 m2 -> m1.hlmt_index - m2.hlmt_index) (List.rev !methods) in
(* done *)
let rec ctx = {
Expand All @@ -898,7 +899,7 @@ let flatten t =
fnames = new_lookup flatten_name;
fmetas = new_lookup flatten_meta;
fmethods = new_index_lookup methods flatten_method;
fclasses = new_index_lookup (List.rev !classes) flatten_class;
fclasses = new_index_lookup classes flatten_class;
fjumps = [];
ffunctions = [];
} in
Expand Down
6 changes: 6 additions & 0 deletions src-json/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -1303,5 +1303,11 @@
"metadata": ":needsExceptionStack",
"doc": "Internally used for some of auto-generated `catch` vars",
"internal": true
},
{
"name": "WrappedException",
"metadata": ":wrappedException",
"doc": "Internally used for exceptions wrapping in `throw` expressions.",
"internal": true
}
]
107 changes: 107 additions & 0 deletions src-json/warning.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
[
{
"name": "WAll",
"doc": "The mother of all warnings",
"generic": true
},
{
"name": "WInternal",
"doc": "Reserved for internal use",
"generic": true
},
{
"name": "WTemp",
"doc": "Reserved for internal use",
"generic": true
},
{
"name": "WInfo",
"doc": "Generic information like $type",
"generic": true
},
{
"name": "WUser",
"doc": "Custom user warnings, e.g. from Context.warning",
"generic": true
},
{
"name": "WCompiler",
"doc": "Warnings from the compiler frontend, e.g. argument parsing",
"generic": true
},
{
"name": "WParser",
"doc": "Warnings related to lexing and parsing",
"generic": true
},
{
"name": "WTyper",
"doc": "Warnings from the typer",
"generic": true
},
{
"name": "WMacro",
"doc": "Warning related to macros",
"generic": true
},
{
"name": "WOptimizer",
"doc": "Warnings related to optimization",
"generic": true
},
{
"name": "WGenerator",
"doc": "Warnings related to code generation",
"generic": true
},
{
"name": "WDeprecated",
"doc": "This is deprecated and should no longer be used"
},
{
"name": "WVarInit",
"doc": "A local variable might be used before being assigned a value",
"parent": "WTyper"
},
{
"name": "WVarShadow",
"doc": "A local variable hides another by using the same name",
"parent": "WTyper"
},
{
"name": "WExternWithExpr",
"doc": "A non-inline field marked as extern has an expression",
"parent": "WTyper"
},
{
"name": "WStaticInitOrder",
"doc": "The compiler could not determine a type order due to mutually dependent static initializations",
"parent": "WTyper"
},
{
"name": "WClosureCompare",
"doc": "Closures are being compared, which might be undefined",
"parent": "WTyper"
},
{
"name": "WReservedTypePath",
"doc": "A type path is being used that is supposed to be reserved on the current target",
"parent": "WTyper"
},
{
"name": "WPatternMatcher",
"doc": "Warnings related to the pattern matcher",
"parent": "WTyper"
},
{
"name": "WUnusedPattern",
"doc": "The pattern is not used because previous cases cover",
"parent": "WPatternMatcher"
},
{
"name": "WConstructorInliningCancelled",
"doc": "Constructor call could not be inlined because a field is uninitialized",
"parent": "WTyper"
}

]
90 changes: 90 additions & 0 deletions src-prebuild/prebuild.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@ open Json

exception Prebuild_error of string

type parsed_warning = {
w_name : string;
w_doc : string;
w_parent : string option;
w_generic : bool;
}

let as_string = function
| JString s -> Some s
| _ -> None

let as_int = function
| JInt i -> Some i
| _ -> None

let as_params = function
| JArray s -> Some (List.map (function
| JString s -> s
Expand Down Expand Up @@ -66,6 +77,16 @@ let get_optional_field name map default fields =
| Some v -> v
with Not_found -> default

let get_optional_field2 name map fields =
try
let field = List.find (fun (n, _) -> n = name) fields in
let value = map (snd field) in
match value with
| None -> raise (Prebuild_error ("field `" ^ name ^ "` has invalid data"))
| Some v -> Some v
with Not_found ->
None

let get_field name map fields =
let field = try List.find (fun (n, _) -> n = name) fields with Not_found -> raise (Prebuild_error ("no `" ^ name ^ "` field")) in
let value = map (snd field) in
Expand Down Expand Up @@ -99,6 +120,18 @@ let parse_meta json =
(* internal *) get_optional_field "internal" as_bool false fields,
(* links *) get_optional_field "links" as_links [] fields

let parse_warning json =
let fields = match json with
| JObject fl -> fl
| _ -> raise (Prebuild_error "not an object")
in
{
w_name = get_field "name" as_string fields;
w_doc = get_field "doc" as_string fields;
w_parent = get_optional_field2 "parent" as_string fields;
w_generic = get_optional_field "generic" as_bool false fields;
}

let parse_file_array path map =
let file = open_in path in
let data = Std.input_all file in
Expand All @@ -109,6 +142,20 @@ let parse_file_array path map =
| JArray s -> List.map map s
| _ -> raise (Prebuild_error "not an array")

let s_escape ?(hex=true) s =
let b = Buffer.create (String.length s) in
for i = 0 to (String.length s) - 1 do
match s.[i] with
| '\n' -> Buffer.add_string b "\\n"
| '\t' -> Buffer.add_string b "\\t"
| '\r' -> Buffer.add_string b "\\r"
| '"' -> Buffer.add_string b "\\\""
| '\\' -> Buffer.add_string b "\\\\"
| c when int_of_char c < 32 && hex -> Buffer.add_string b (Printf.sprintf "\\x%.2X" (int_of_char c))
| c -> Buffer.add_char b c
done;
Buffer.contents b

let gen_platforms = function
| [] -> []
| platforms -> ["Platforms [" ^ (String.concat ";" platforms) ^ "]"]
Expand Down Expand Up @@ -157,6 +204,32 @@ let gen_meta_info metas =
) metas in
String.concat "\n" meta_str

let gen_warning_type warnings =
let warning_str = List.map (function
w ->
Printf.sprintf "\t| %s" w.w_name
) warnings in
String.concat "\n" warning_str

let gen_warning_parse warnings =
let warning_str = List.map (function
w ->
Printf.sprintf "\t| \"%s\" -> %s" w.w_name w.w_name
) warnings in
let warning_str = warning_str @ ["\t| _ -> raise Exit"] in
String.concat "\n" warning_str


let gen_warning_obj warnings =
let warning_str = List.map (fun w ->
let w_parent = match w.w_parent with
| None -> if w.w_name = "WAll" then "None" else "Some WAll"
| Some w -> Printf.sprintf "Some %s" w
in
Printf.sprintf "\t| %s -> {w_name = \"%s\"; w_doc = \"%s\"; w_generic = %b; w_parent = %s}" w.w_name w.w_name (s_escape w.w_doc) w.w_generic w_parent
) warnings in
String.concat "\n" warning_str

let autogen_header = "(* This file is auto-generated using prebuild from files in src-json *)
(* Do not edit manually! *)
"
Expand Down Expand Up @@ -216,6 +289,23 @@ match Array.to_list (Sys.argv) with
Printf.printf "let get_info = function\n";
Printf.printf "%s" (gen_meta_info metas);
Printf.printf "\n\t| Last -> die \"\" __LOC__\n\t| Dollar s -> \"$\" ^ s,(\"\",[])\n\t| Custom s -> s,(\"\",[])\n"
| [_; "warning"; warning_path]->
let warnings = parse_file_array warning_path parse_warning in
print_endline "type warning =";
print_endline (gen_warning_type warnings);
print_endline "";
print_endline "type warning_obj = {";
print_endline "\tw_name : string;";
print_endline "\tw_doc : string;";
print_endline "\tw_generic : bool;";
print_endline "\tw_parent : warning option;";
print_endline "}";
print_endline "";
print_endline "let warning_obj = function";
print_endline (gen_warning_obj warnings);
print_endline "";
print_endline "let from_string = function";
print_endline (gen_warning_parse warnings);
| _ :: "libparams" :: params ->
Printf.printf "(%s)" (String.concat " " (List.map (fun s -> Printf.sprintf "\"%s\"" s) params))
| [_ ;"version";add_revision;branch;sha] ->
Expand Down
20 changes: 10 additions & 10 deletions src/codegen/gencommon/castDetect.ml
Original file line number Diff line number Diff line change
Expand Up @@ -767,12 +767,12 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
| [Cannot_unify (b, TAbstract(a,params))] ->
let a = apply_params a.a_params params a.a_this in
if not (shallow_eq a b) then
gen.gwarning WGencommon ("This expression may be invalid") pos
gen.gwarning WGenerator ("This expression may be invalid") pos
| _ ->
gen.gwarning WGencommon ("This expression may be invalid") pos
gen.gwarning WGenerator ("This expression may be invalid") pos
)
| Invalid_argument _ ->
gen.gwarning WGencommon ("This expression may be invalid") pos
gen.gwarning WGenerator ("This expression may be invalid") pos
);

List.map (fun t ->
Expand Down Expand Up @@ -824,7 +824,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
(* f,f.cf_type, false *)
select_overload gen e1.etype ((f.cf_type,f) :: List.map (fun f -> f.cf_type,f) f.cf_overloads) [] [], true
| _ ->
gen.gwarning WGencommon "Overloaded classfield typed as anonymous" ecall.epos;
gen.gwarning WGenerator "Overloaded classfield typed as anonymous" ecall.epos;
(cf, actual_t, true), true
in

Expand All @@ -847,7 +847,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
end;
{ cf_orig with cf_name = cf.cf_name },actual_t,false
| None ->
gen.gwarning WGencommon "Cannot find matching overload" ecall.epos;
gen.gwarning WGenerator "Cannot find matching overload" ecall.epos;
cf, actual_t, true
else
cf,actual_t,error
Expand Down Expand Up @@ -929,7 +929,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
elist);
}, elist
with Invalid_argument _ ->
gen.gwarning WGencommon ("This expression may be invalid" ) ecall.epos;
gen.gwarning WGenerator ("This expression may be invalid" ) ecall.epos;
{ ecall with eexpr = TCall({ e1 with eexpr = TField(!ef, f) }, elist) }, elist
in
let new_ecall = if fparams <> [] then gen.gparam_func_call new_ecall { e1 with eexpr = TField(!ef, f) } fparams elist else new_ecall in
Expand Down Expand Up @@ -959,7 +959,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
*)
| _ ->
let pt = match e with | None -> real_type | Some _ -> snd (get_fun e1.etype) in
let _params = match follow pt with | TEnum(_, p) -> p | _ -> gen.gwarning WGencommon (debug_expr e1) e1.epos; die "" __LOC__ in
let _params = match follow pt with | TEnum(_, p) -> p | _ -> gen.gwarning WGenerator (debug_expr e1) e1.epos; die "" __LOC__ in
let args, ret = get_fun efield.ef_type in
let actual_t = TFun(List.map (fun (n,o,t) -> (n,o,gen.greal_type t)) args, gen.greal_type ret) in
(*
Expand Down Expand Up @@ -1143,7 +1143,7 @@ let configure gen ?(overloads_cast_to_base = false) maybe_empty_t calls_paramete
let base_type = match follow et with
| TInst({ cl_path = ([], "Array") } as cl, bt) -> gen.greal_type_param (TClassDecl cl) bt
| _ ->
gen.gwarning WGencommon (debug_type et) e.epos;
gen.gwarning WGenerator (debug_type et) e.epos;
(match gen.gcurrent_class with
| Some cl -> print_endline (s_type_path cl.cl_path)
| _ -> ());
Expand Down Expand Up @@ -1187,7 +1187,7 @@ let configure gen ?(overloads_cast_to_base = false) maybe_empty_t calls_paramete
) (wrap_rest_args gen (TFun (args,rt)) eparams e.epos) args in
{ e with eexpr = TCall(ef, eparams) }
with | Not_found ->
gen.gwarning WGencommon "No overload found for this constructor call" e.epos;
gen.gwarning WGenerator "No overload found for this constructor call" e.epos;
{ e with eexpr = TCall(ef, List.map run eparams) })
| TCall (ef, eparams) ->
(match ef.etype with
Expand Down Expand Up @@ -1215,7 +1215,7 @@ let configure gen ?(overloads_cast_to_base = false) maybe_empty_t calls_paramete
) (wrap_rest_args gen (TFun (args,rt)) eparams e.epos) args in
{ e with eexpr = TNew(cl, tparams, eparams) }
with | Not_found ->
gen.gwarning WGencommon "No overload found for this constructor call" e.epos;
gen.gwarning WGenerator "No overload found for this constructor call" e.epos;
{ e with eexpr = TNew(cl, tparams, List.map run eparams) })
| TUnop((Increment | Decrement) as op, flag, ({ eexpr = TArray (arr, idx) } as e2))
when (match follow arr.etype with TInst({ cl_path = ["cs"],"NativeArray" },_) -> true | _ -> false) ->
Expand Down
6 changes: 3 additions & 3 deletions src/codegen/gencommon/closuresToClass.ml
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ let configure gen ft =
with
| Not_found ->
if in_tparam then begin
gen.gwarning WGencommon "This expression may be invalid" e.epos;
gen.gwarning WGenerator "This expression may be invalid" e.epos;
e
end else
(* It is possible that we are recursively calling a function
Expand All @@ -642,8 +642,8 @@ let configure gen ft =
(Meta.Custom(":tparamcall"), [], e.epos), e
) }
| Unify_error el ->
List.iter (fun el -> gen.gwarning WGencommon (Error.unify_error_msg (print_context()) el) e.epos) el;
gen.gwarning WGencommon "This expression may be invalid" e.epos;
List.iter (fun el -> gen.gwarning WGenerator (Error.unify_error_msg (print_context()) el) e.epos) el;
gen.gwarning WGenerator "This expression may be invalid" e.epos;
e
)
(* (handle_anon_func:texpr->tfunc->texpr) (dynamic_func_call:texpr->texpr->texpr list->texpr) *)
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/gencommon/gencommon.ml
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ let new_ctx con =

greal_field_types = Hashtbl.create 0;
ghandle_cast = (fun to_t from_t e -> mk_cast to_t e);
gon_unsafe_cast = (fun t t2 pos -> (gen.gwarning WGencommon ("Type " ^ (debug_type t2) ^ " is being cast to the unrelated type " ^ (s_type (print_context()) t)) pos));
gon_unsafe_cast = (fun t t2 pos -> (gen.gwarning WGenerator ("Type " ^ (debug_type t2) ^ " is being cast to the unrelated type " ^ (s_type (print_context()) t)) pos));
gneeds_box = (fun t -> false);
gspecial_needs_cast = (fun to_t from_t -> false);
gsupported_conversions = Hashtbl.create 0;
Expand Down
Loading

0 comments on commit 0dca14a

Please sign in to comment.