Skip to content

Commit

Permalink
disallow ?.new and ?.match
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Oct 22, 2024
1 parent cf4d729 commit b4695ee
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/typing/typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,8 @@ and type_access ctx e p mode with_type =
match e with
| EConst (Ident s) ->
type_ident ctx s p mode with_type
| EField (e1,"new",efk_todo) ->
| EField (e1,"new",efk) ->
if efk = EFSafe then raise_typing_error "?.new is not supported" p;
let e1 = type_expr ctx e1 WithType.value in
begin match e1.eexpr with
| TTypeExpr (TClassDecl c) ->
Expand Down Expand Up @@ -1752,7 +1753,8 @@ and type_call_builtin ctx e el mode with_type p =
in
warning ctx WInfo s e1.epos;
e1
| (EField(e,"match",efk_todo),p), [epat] ->
| (EField(e,"match",efk),p), [epat] ->
if efk = EFSafe then raise_typing_error "?.match is not supported" p;
let et = type_expr ctx e WithType.value in
let rec has_enum_match t = match follow t with
| TEnum _ -> true
Expand Down
3 changes: 3 additions & 0 deletions tests/misc/projects/Issue11571/MainMatch.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function main() {
(macro 1).expr?.match(1);
}
3 changes: 3 additions & 0 deletions tests/misc/projects/Issue11571/MainNew.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function main() {
String?.new;
}
2 changes: 2 additions & 0 deletions tests/misc/projects/Issue11571/compile-match-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--main MainMatch
--interp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MainMatch.hx:2: characters 2-23 : ?.match is not supported
2 changes: 2 additions & 0 deletions tests/misc/projects/Issue11571/compile-new-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--main MainNew
--interp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MainNew.hx:2: characters 2-13 : ?.new is not supported

0 comments on commit b4695ee

Please sign in to comment.