[erl-frontend] Support bitwise not operation

Summary: Add support for bitwise not (unary).

Reviewed By: mmarescotti

Differential Revision: D29968081

fbshipit-source-id: fddf2e9dc
master
Akos Hajdu 3 years ago committed by Facebook GitHub Bot
parent 2fbcd3b38d
commit ad09c1cda6

@ -576,15 +576,12 @@ and translate_expression env {Ast.line; simple_expression} =
in
let op_block =
match op with
| UBNot ->
make_simple_op_block BNot
| UMinus ->
make_simple_op_block Neg
| UNot ->
make_simple_op_block LNot
| todo ->
L.debug Capture Verbose
"@[todo ErlangTranslator.translate_expression(UnaryOperator) %s@."
(Sexp.to_string (Ast.sexp_of_unary_operator todo)) ;
Block.make_success env
in
Block.all env [block; op_block]
| Variable vname ->

@ -20,6 +20,8 @@ codetoanalyze/erlang/features/src/bitwise.erl, test_bsr1_Bad/0, -107, NO_MATCHIN
codetoanalyze/erlang/features/src/bitwise.erl, test_bsr2_Bad/0, -121, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no matching function clause here]
codetoanalyze/erlang/features/src/bitwise.erl, test_bxor1_Bad/0, -65, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no matching function clause here]
codetoanalyze/erlang/features/src/bitwise.erl, test_bxor2_Bad/0, -79, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no matching function clause here]
codetoanalyze/erlang/features/src/bitwise.erl, test_ubnot1_Bad/0, -134, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no matching function clause here]
codetoanalyze/erlang/features/src/bitwise.erl, test_ubnot2_Bad/0, -146, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no matching function clause here]
codetoanalyze/erlang/features/src/bitwise.erl, warn/1, 0, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [*** LATENT ***,no matching function clause here]
codetoanalyze/erlang/features/src/block.erl, test_block_Bad/0, -15, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no matching function clause here]
codetoanalyze/erlang/features/src/block.erl, warn/1, 0, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [*** LATENT ***,no matching function clause here]

@ -23,7 +23,11 @@
test_bsr1_Ok/0,
test_bsr1_Bad/0,
test_bsr2_Ok/0,
test_bsr2_Bad/0
test_bsr2_Bad/0,
test_ubnot1_Ok/0,
test_ubnot1_Bad/0,
test_ubnot2_Ok/0,
test_ubnot2_Bad/0
]).
% Call this method with warn(1) to trigger a warning to expect
@ -154,3 +158,27 @@ test_bsr2_Bad() ->
case X bsr Y of
0 -> warn(1)
end.
test_ubnot1_Ok() ->
X = 1,
case bnot X of
-2 -> ok
end.
test_ubnot1_Bad() ->
X = 1,
case bnot X of
-2 -> warn(1)
end.
test_ubnot2_Ok() ->
X = 11,
case bnot X of
-12 -> ok
end.
test_ubnot2_Bad() ->
X = 11,
case bnot X of
-12 -> warn(1)
end.

Loading…
Cancel
Save