[erl-frontend] Support block expressions

Summary: Add support for block expressions in the translation.

Reviewed By: rgrig

Differential Revision: D29584072

fbshipit-source-id: 2a1a1eeda
master
Akos Hajdu 4 years ago committed by Facebook GitHub Bot
parent 87626160aa
commit c82308e586

@ -367,6 +367,8 @@ and translate_expression env {Ast.line; simple_expression} =
Block.make_success env Block.make_success env
in in
Block.all env [block1; block2; op_block] Block.all env [block1; block2; op_block]
| Block body ->
translate_body env body
| Call | Call
{ module_= None { module_= None
; function_= {Ast.line= _; simple_expression= Literal (Atom function_name)} ; function_= {Ast.line= _; simple_expression= Literal (Atom function_name)}

@ -11,3 +11,5 @@ codetoanalyze/erlang/features/src/arithmetic.erl, test_sub2_Bad/0, -54, NONEXHAU
codetoanalyze/erlang/features/src/arithmetic.erl, test_uminus1_Bad/0, -170, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no pattern match here] codetoanalyze/erlang/features/src/arithmetic.erl, test_uminus1_Bad/0, -170, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no pattern match here]
codetoanalyze/erlang/features/src/arithmetic.erl, test_uminus2_Bad/0, -183, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no pattern match here] codetoanalyze/erlang/features/src/arithmetic.erl, test_uminus2_Bad/0, -183, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no pattern match here]
codetoanalyze/erlang/features/src/arithmetic.erl, warn/1, 0, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [*** LATENT ***,no pattern match here] codetoanalyze/erlang/features/src/arithmetic.erl, warn/1, 0, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [*** LATENT ***,no pattern match here]
codetoanalyze/erlang/features/src/block.erl, test_block_Bad/0, -15, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no pattern match here]
codetoanalyze/erlang/features/src/block.erl, warn/1, 0, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [*** LATENT ***,no pattern match here]

@ -0,0 +1,37 @@
% Copyright (c) Facebook, Inc. and its affiliates.
%
% This source code is licensed under the MIT license found in the
% LICENSE file in the root directory of this source tree.
-module(block).
-export([test_block_Ok/0, test_block_Bad/0]).
% Call this method with warn(1) to trigger a warning to expect
warn(0) -> ok.
test_block_Ok() ->
case
begin
X = 3,
Y = X,
Z = Y,
Z
end
of
3 -> ok;
_ -> warn(1)
end.
test_block_Bad() ->
case
begin
X = 3,
Y = X,
Z = Y,
Z
end
of
3 -> warn(1);
_ -> ok
end.
Loading…
Cancel
Save