Skip to content

Commit

Permalink
Merge tag '4.3.2'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/main.yml
#	extra/github-actions/build-mac.yml
#	extra/github-actions/build-windows.yml
#	extra/github-actions/workflows/main.yml
  • Loading branch information
RobDangerous committed Sep 7, 2023
2 parents 74a8bcc + a6ac3ae commit ee9f2c3
Show file tree
Hide file tree
Showing 62 changed files with 546 additions and 167 deletions.
27 changes: 27 additions & 0 deletions extra/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
2023-09-01 4.3.2

General improvements:

all : do not raise error on no-op reification outside macro

Bugfixes:

all : don't infer Null<?> if it already is Null<?> (#11286)
all : fix ?? inference and precedence (#11252)
all : bring back forced inline (#11217)
all : allow non constant "inline" var init with -D no-inline (#11192)
all : improve @:enum abstract deprecation warning handling (#11302)
all : fix some stack overflow with pretty errors
display : fix go to definition with final (#11173)
display : fix completion requests with @:forwardStatics (#11294)
eval : fix MainLoop.add not repeating (#11202)
hl/eval/neko : fix exception stack when wrapping native exceptions (#11249)
macro : map `this` when restoring typed expressions (#11212)
macro : safe navigation fix for ExprTools.map (#11204)
macro : safe navigation fix for haxe.macro.Printer (#11206)
macro : macro generated EVars position fixes (#11163)
macro : fix abstract casts for local statics (#11301)
macro : add flags to TDAbstract to be able to construct enum abstracts (#11230)
nullsafety : make break/continue expressions not-nullable (#11269)
nullsafety : handle return in assignment (#11114)

2023-04-28 4.3.1

Breaking changes:
Expand Down
2 changes: 1 addition & 1 deletion extra/github-actions/build-mac.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- name: Install dependencies
env:
# For compatibility with macOS 10.13
ZLIB_VERSION: 1.2.13
ZLIB_VERSION: 1.3
MBEDTLS_VERSION: 2.25.0
PCRE2_VERSION: 10.42
run: |
Expand Down
2 changes: 1 addition & 1 deletion extra/github-actions/install-nsis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: choco install nsis
uses: nick-invision/retry@v1
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 10
Expand Down
4 changes: 2 additions & 2 deletions extra/github-actions/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
FORCE_COLOR: 1
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -130,7 +130,7 @@ jobs:

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:latest
platforms: all
Expand Down
2 changes: 1 addition & 1 deletion haxe.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
opam-version: "2.0"
name: "haxe"
version: "4.3.1"
version: "4.3.2"
synopsis: "Multi-target universal programming language"
description: """
Haxe is an open source toolkit based on a modern,
Expand Down
5 changes: 5 additions & 0 deletions src-json/warning.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
"doc": "This define is deprecated and should no longer be used",
"parent": "WDeprecated"
},
{
"name": "WDeprecatedEnumAbstract",
"doc": "`@:enum abstract` is deprecated, `enum abstract` should be used instead",
"parent": "WDeprecated"
},
{
"name": "WVarInit",
"doc": "A local variable might be used before being assigned a value",
Expand Down
53 changes: 25 additions & 28 deletions src/compiler/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,39 +121,36 @@ module Communication = struct
end
in

try
let read_char line = match input_char_or_done ch line with
| '\n' -> inc 1 line
| '\r' ->
ignore(input_char_or_done ch line);
inc 2 line
| c -> begin
let line = ref (line ^ (String.make 1 c)) in
let rec skip n =
if n > 0 then begin
let c = input_char_or_done ch !line in
line := !line ^ (String.make 1 c);
skip (n - 1)
end
in
let read_char line = match input_char_or_done ch line with
| '\n' -> inc 1 line
| '\r' ->
ignore(input_char_or_done ch line);
inc 2 line
| c -> begin
let line = ref (line ^ (String.make 1 c)) in
let rec skip n =
if n > 0 then begin
let c = input_char_or_done ch !line in
line := !line ^ (String.make 1 c);
skip (n - 1)
end
in

let code = int_of_char c in
if code < 0xC0 then ()
else if code < 0xE0 then skip 1
else if code < 0xF0 then skip 2
else skip 3;
let code = int_of_char c in
if code < 0xC0 then ()
else if code < 0xE0 then skip 1
else if code < 0xF0 then skip 2
else skip 3;

(1, !line)
end
in
(1, !line)
end
in

let (delta, line) = read_char line in
loop (p + delta) line
with End_of_file ->
close_in ch;
let (delta, line) = read_char line in
loop (p + delta) line
in

loop 0 "";
try loop 0 ""; with End_of_file -> close_in ch;
List.rev !lines

let resolve_file ctx f =
Expand Down
34 changes: 19 additions & 15 deletions src/context/display/displayFields.ml
Original file line number Diff line number Diff line change
Expand Up @@ -228,21 +228,25 @@ let collect ctx e_ast e dk with_type p =
| TAnon an ->
(* @:forwardStatics *)
let items = match !(an.a_status) with
| Statics { cl_kind = KAbstractImpl { a_meta = meta; a_this = TInst (c,_) }} when Meta.has Meta.ForwardStatics meta ->
let items = List.fold_left (fun acc cf ->
if should_access c cf true && is_new_item acc cf.cf_name then begin
let origin = Self(TClassDecl c) in
let item = make_class_field origin cf in
PMap.add cf.cf_name item acc
end else
acc
) items c.cl_ordered_statics in
PMap.foldi (fun name item acc ->
if is_new_item acc name then
PMap.add name item acc
else
acc
) PMap.empty items
| Statics { cl_kind = KAbstractImpl { a_meta = meta; a_this}} when Meta.has Meta.ForwardStatics meta ->
begin match follow a_this with
| TInst (c,_) ->
let items = List.fold_left (fun acc cf ->
if should_access c cf true && is_new_item acc cf.cf_name then begin
let origin = Self(TClassDecl c) in
let item = make_class_field origin cf in
PMap.add cf.cf_name item acc
end else
acc
) items c.cl_ordered_statics in
PMap.foldi (fun name item acc ->
if is_new_item acc name then
PMap.add name item acc
else
acc
) PMap.empty items
| _ -> items
end
| _ -> items
in
(* Anon own fields *)
Expand Down
14 changes: 10 additions & 4 deletions src/context/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,16 @@ let is_removable_field com f =
| _ -> false)
)

let is_forced_inline c cf =
match c with
| Some { cl_kind = KAbstractImpl _ } -> true
| Some c when has_class_flag c CExtern -> true
| _ when has_class_field_flag cf CfExtern -> true
| _ -> false

let needs_inline ctx c cf =
cf.cf_kind = Method MethInline && ctx.allow_inline && (ctx.g.doinline || is_forced_inline c cf)

(** checks if we can access to a given class field using current context *)
let rec can_access ctx c cf stat =
if (has_class_field_flag cf CfPublic) then
Expand Down Expand Up @@ -703,10 +713,6 @@ let get_next_stored_typed_expr_id =
let uid = ref 0 in
(fun() -> incr uid; !uid)

let get_stored_typed_expr com id =
let e = com.stored_typed_exprs#find id in
Texpr.duplicate_tvars e

let store_typed_expr com te p =
let id = get_next_stored_typed_expr_id() in
com.stored_typed_exprs#add id te;
Expand Down
2 changes: 1 addition & 1 deletion src/core/globals.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type platform =
| Hl
| Eval

let version = 4301
let version = 4302
let version_major = version / 1000
let version_minor = (version mod 1000) / 100
let version_revision = (version mod 100)
Expand Down
6 changes: 5 additions & 1 deletion src/core/texpr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ let rec equal e1 e2 = match e1.eexpr,e2.eexpr with
| TEnumParameter(e1,ef1,i1),TEnumParameter(e2,ef2,i2) -> equal e1 e2 && ef1 == ef2 && i1 = i2
| _ -> false

let duplicate_tvars e =
let e_identity e = e

let duplicate_tvars f_this e =
let vars = Hashtbl.create 0 in
let copy_var v =
let v2 = alloc_var v.v_kind v.v_name v.v_type v.v_pos in
Expand Down Expand Up @@ -336,6 +338,8 @@ let duplicate_tvars e =
{e with eexpr = TLocal v2}
with _ ->
e)
| TConst TThis ->
f_this e
| _ ->
map_expr build_expr e
in
Expand Down
6 changes: 4 additions & 2 deletions src/filters/exceptions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,11 @@ let catch_native ctx catches t p =
)
(* Haxe-specific wildcard catches should go to if-fest because they need additional handling *)
| (v,_) :: _ when is_haxe_wildcard_catch ctx v.v_type ->
(match handle_as_value_exception with
| [] ->
(match handle_as_value_exception, value_exception_catch with
| [], None ->
catches_to_ifs ctx catches t p
| [], Some catch ->
catches_to_ifs ctx [catch] t p
| _ ->
catches_as_value_exception ctx handle_as_value_exception None t p
:: catches_to_ifs ctx catches t p
Expand Down
19 changes: 15 additions & 4 deletions src/macro/macroApi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ and encode_expr e =
10, [encode_array (List.map (fun v ->
encode_obj [
"name",encode_placed_name v.ev_name;
"name_pos",encode_pos (pos v.ev_name);
"namePos",encode_pos (pos v.ev_name);
"isFinal",vbool v.ev_final;
"isStatic",vbool v.ev_static;
"type",null encode_ctype v.ev_type;
Expand Down Expand Up @@ -907,7 +907,9 @@ and decode_expr v =
let static = if vstatic == vnull then false else decode_bool vstatic in
let vmeta = field v "meta" in
let meta = if vmeta == vnull then [] else decode_meta_content vmeta in
let name = (decode_placed_name (field v "name_pos") (field v "name"))
let name_pos = maybe_decode_pos (field v "namePos") in
let name_pos = if name_pos = null_pos then p else name_pos in
let name = ((decode_string (field v "name")), name_pos)
and t = opt decode_ctype (field v "type")
and eo = opt loop (field v "expr") in
mk_evar ~final ~static ?t ?eo ~meta name
Expand Down Expand Up @@ -1621,10 +1623,19 @@ let decode_type_def v =
EClass (mk flags fields)
| 3, [t] ->
ETypedef (mk (if isExtern then [EExtern] else []) (decode_ctype t))
| 4, [tthis;tfrom;tto] ->
let flags = match opt decode_array tfrom with None -> [] | Some ta -> List.map (fun t -> AbFrom (decode_ctype t)) ta in
| 4, [tthis;tflags;tfrom;tto] ->
let flags = match opt decode_array tflags with
| None -> []
| Some ta -> List.map (fun f -> match decode_enum f with
| 0, [] -> AbEnum
| 1, [ct] -> AbFrom (decode_ctype ct)
| 2, [ct] -> AbTo (decode_ctype ct)
| _ -> raise Invalid_expr
) ta in
let flags = match opt decode_array tfrom with None -> flags | Some ta -> List.map (fun t -> AbFrom (decode_ctype t)) ta @ flags in
let flags = match opt decode_array tto with None -> flags | Some ta -> (List.map (fun t -> AbTo (decode_ctype t)) ta) @ flags in
let flags = match opt decode_ctype tthis with None -> flags | Some t -> (AbOver t) :: flags in
let flags = if isExtern then AbExtern :: flags else flags in
EAbstract(mk flags fields)
| 5, [fk;al] ->
let fk = decode_class_field_kind fk in
Expand Down
2 changes: 1 addition & 1 deletion src/optimization/analyzerTexpr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ module TexprFilter = struct
let e_if eo = mk (TIf(e_not,e_break,eo)) com.basic.tvoid p in
let rec map_continue e = match e.eexpr with
| TContinue ->
Texpr.duplicate_tvars (e_if (Some e))
Texpr.duplicate_tvars e_identity (e_if (Some e))
| TWhile _ | TFor _ ->
e
| _ ->
Expand Down
8 changes: 2 additions & 6 deletions src/optimization/inline.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ open Common
open Typecore
open Error

let needs_inline ctx is_extern_class cf =
cf.cf_kind = Method MethInline && ctx.allow_inline
&& (ctx.g.doinline || is_extern_class || has_class_field_flag cf CfExtern)

let mk_untyped_call name p params =
{
eexpr = TCall({ eexpr = TIdent name; etype = t_dynamic; epos = p }, params);
Expand Down Expand Up @@ -510,14 +506,14 @@ class inline_state ctx ethis params cf f p = object(self)
| VIInline ->
begin match e'.eexpr with
(* If we inline a function expression, we have to duplicate its locals. *)
| TFunction _ -> Texpr.duplicate_tvars e'
| TFunction _ -> Texpr.duplicate_tvars e_identity e'
| TCast(e1,None) when in_assignment -> e1
| _ -> e'
end
| VIInlineIfCalled when in_call ->
(* We allow inlining function expressions into call-places. However, we have to substitute
their locals to avoid duplicate declarations. *)
Texpr.duplicate_tvars e'
Texpr.duplicate_tvars e_identity e'
| _ -> e
end
with Not_found ->
Expand Down
6 changes: 3 additions & 3 deletions src/optimization/inlineConstructors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ let inline_constructors ctx original_e =
| TNew _, true ->
true, false
| TNew({ cl_constructor = Some ({cf_kind = Method MethInline; cf_expr = Some ({eexpr = TFunction _})} as cf)} as c,_,_), _ ->
Inline.needs_inline ctx (has_class_flag c CExtern) cf, false
needs_inline ctx (Some c) cf, false
| _ -> false, false
in
is_ctor || Type.check_expr (check_for_ctors ~force_inline:is_meta_inline) e
Expand All @@ -237,7 +237,7 @@ let inline_constructors ctx original_e =
| TNew _, true ->
mark()
| TNew({ cl_constructor = Some ({cf_kind = Method MethInline; cf_expr = Some ({eexpr = TFunction _})} as cf)} as c,_,_), _ ->
if Inline.needs_inline ctx (has_class_flag c CExtern) cf then mark()
if needs_inline ctx (Some c) cf then mark()
else e
| _ -> e
in
Expand Down Expand Up @@ -285,7 +285,7 @@ let inline_constructors ctx original_e =
let f = PMap.find fname ctor.ioc_class.cl_fields in
begin match f.cf_params, f.cf_kind, f.cf_expr with
| [], Method MethInline, Some({eexpr = TFunction tf}) ->
if Inline.needs_inline ctx (has_class_flag ctor.ioc_class CExtern) f then
if needs_inline ctx (Some ctor.ioc_class) f then
Some (ctor.ioc_class, ctor.ioc_tparams, f, tf)
else
None
Expand Down
2 changes: 1 addition & 1 deletion src/optimization/optimizer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ let rec reduce_loop ctx e =
(match inl with
| None -> reduce_expr ctx e
| Some e -> reduce_loop ctx e)
| {eexpr = TField(ef,(FStatic(cl,cf) | FInstance(cl,_,cf)))} when needs_inline ctx (has_class_flag cl CExtern) cf && not (rec_stack_memq cf inline_stack) ->
| {eexpr = TField(ef,(FStatic(cl,cf) | FInstance(cl,_,cf)))} when needs_inline ctx (Some cl) cf && not (rec_stack_memq cf inline_stack) ->
begin match cf.cf_expr with
| Some {eexpr = TFunction tf} ->
let config = inline_config (Some cl) cf el e.etype in
Expand Down
13 changes: 7 additions & 6 deletions src/syntax/parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,13 @@ let precedence op =
| OpAdd | OpSub -> 3, left
| OpShl | OpShr | OpUShr -> 4, left
| OpOr | OpAnd | OpXor -> 5, left
| OpEq | OpNotEq | OpGt | OpLt | OpGte | OpLte -> 6, left
| OpInterval -> 7, left
| OpBoolAnd -> 8, left
| OpBoolOr | OpNullCoal -> 9, left
| OpArrow -> 10, right
| OpAssign | OpAssignOp _ -> 11, right
| OpNullCoal -> 6, left
| OpEq | OpNotEq | OpGt | OpLt | OpGte | OpLte -> 7, left
| OpInterval -> 8, left
| OpBoolAnd -> 9, left
| OpBoolOr -> 10, left
| OpArrow -> 11, right
| OpAssign | OpAssignOp _ -> 12, right

let is_higher_than_ternary = function
| OpAssign | OpAssignOp _ | OpArrow -> false
Expand Down
Loading

0 comments on commit ee9f2c3

Please sign in to comment.