Skip to content

Commit 47c8b58

Browse files
authored
Merge pull request #489 from ferd/maybe_expr_unsupported
Add known problem for unsupported maybe expression
2 parents 7773a04 + da382b5 commit 47c8b58

16 files changed

+84
-32
lines changed

.github/workflows/build-and-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ on:
99

1010
jobs:
1111
test:
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-20.04
1313
name: Erlang ${{matrix.otp}}
1414
strategy:
1515
matrix:
16-
otp: ['22.3.4.20', '23.3.4.7', '24.3.4.4']
16+
otp: ['23.3.4.7', '24.3.4.4', '25.1.2']
1717
steps:
1818
- uses: actions/checkout@v2
1919
- uses: erlef/setup-beam@v1

.github/workflows/proptests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
test:
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-20.04
1313
name: Erlang ${{matrix.otp}}
1414
strategy:
1515
matrix:

.github/workflows/publish-to-hex.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
publish:
8-
runs-on: ubuntu-latest
8+
runs-on: ubuntu-20.04
99

1010
steps:
1111
- name: Check Out

.github/workflows/self-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
test:
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-20.04
1313
name: Erlang ${{matrix.otp}}
1414
strategy:
1515
matrix:

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
.PHONY: all
3333
all: app escript
3434

35+
ERL_OPTS = -enable-feature maybe_expr
36+
3537
# Compilation
3638

3739
erls = $(wildcard src/*.erl)
@@ -143,7 +145,7 @@ end
143145
endef
144146

145147
eunit: compile-tests
146-
erl -noinput -pa ebin -pa test -eval \
148+
erl $(ERL_OPTS) -noinput -pa ebin -pa test -eval \
147149
'$(erl_run_eunit), halt().'
148150

149151
cli-tests: bin/gradualizer test/arg.beam

rebar.config

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
{deps,
55
[
66
{proper, {git, "https://github.com/proper-testing/proper.git", {branch, "master"}}}
7-
]}
7+
]},
8+
%% see the maybe expression fail;
9+
%% the VM also needs to be configured to load the module
10+
{erl_opts, [{feature,maybe_expr,enable}]}
811
]}
912
]}.
1013

src/gradualizer_fmt.erl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,12 @@ format_type_error({form_check_timeout, Form}, Opts) ->
362362
[form_info(Form),
363363
format_location(Form, verbose, Opts)])
364364
end]);
365+
format_type_error({unsupported_expression, Anno, Expr}, Opts) ->
366+
io_lib:format(
367+
"~sThe ~s expression~s is not supported yet~n",
368+
[format_location(Anno, brief, Opts),
369+
atom_to_list(element(1, Expr)),
370+
format_location(Anno, verbose, Opts)]);
365371
format_type_error({Location, Module, ErrorDescription}, Opts)
366372
when is_integer(Location) orelse is_tuple(Location),
367373
is_atom(Module) ->

src/typechecker.erl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,12 @@ do_type_check_expr(Env, {'try', _, Block, CaseCs, CatchCs, AfterBlock}) ->
19031903
end,
19041904
{normalize({type, erl_anno:new(0), union, [Ty, TyC, TyS]}, Env)
19051905
,VB
1906-
,constraints:combine([Cs1,Cs2,Cs3,Cs4])}.
1906+
,constraints:combine([Cs1,Cs2,Cs3,Cs4])};
1907+
1908+
%% Maybe - value-based error handling expression
1909+
%% See https://www.erlang.org/eeps/eep-0049
1910+
do_type_check_expr(Env, {'maybe', Anno, [{maybe_match, _, _LHS, _RHS}]} = MaybeExpr) ->
1911+
erlang:throw({unsupported_expression, Anno, MaybeExpr}).
19071912

19081913
%% Helper for type_check_expr for funs
19091914
-spec type_check_fun(env(), _) -> {type(), env(), constraints:constraints()}.

test/known_problems/should_pass/any_doesnt_have_type_none_should_pass.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
-module(any_doesnt_have_type_none_should_pass).
22

3+
-export([f/2]).
4+
35
-type type() :: abstract_type().
46

57
-type abstract_type() :: af_tuple_type().

test/known_problems/should_pass/fun_subtyping.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-module(fun_subtyping).
22

3-
-compile([export_all, nowarn_export_all]).
3+
-export([return_fun_intersection/0]).
44

55
-spec return_fun_intersection() -> fun((number()) -> number()).
66
return_fun_intersection() -> fun number/1.

0 commit comments

Comments
 (0)