__OwnedMutable
commit51daefa61e9f6c5e6781c853ec558796e38db4fd
authorVladimir Matveev <vladima@fb.com>
Sun, 21 Oct 2018 00:57:27 +0000 (20 17:57 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Sun, 21 Oct 2018 00:59:44 +0000 (20 17:59 -0700)
tree889ddf7a9ea626409a9af8563de26ac101bb606a
parent2634853cbd06a04085cf627609cc0f5625431cf8
__OwnedMutable

Summary:
This diff introduces `__OwnedMutable` annotation that can be applied to only function parameters. When calling a function the only valid values of argument for parameter with `__OwnedMutable` are:
- `Rx\move(mutably-owned-local)`
- `Rx\mutable(new-or-call-expression)`

Also this diff introduces `Rx\move` intrinsic and changes the semantics of `Rx\freeze` to be aligned with `Rx\move`. In pseudocode:
```
namespace Rx;
<<__Rx, __MutableReturn>>
function move<T>(inout T $v): T {
   $tmp = $v; // grab the referenced value
   unset(v);   // unset local at the callsite
   return $tmp; // return mutably owned value
}
<<__Rx>>
function freeze<T>(inout T $v): T {
   $tmp = $v; // grab the referenced value
   unset(v);   // unset local at the callsite
   return $tmp; // return immutable value
}

```

Reviewed By: DavidSnider

Differential Revision: D10367849

fbshipit-source-id: 0280dc74c5d47d65341ba260ecd3693dbdeb0ba2
105 files changed:
hphp/hack/hhi/rx/functions.hhi
hphp/hack/src/decl/decl.ml
hphp/hack/src/errors/error_codes.ml
hphp/hack/src/errors/errors.ml
hphp/hack/src/errors/errors_sig.ml
hphp/hack/src/naming/naming_special_names.ml
hphp/hack/src/parser/full_fidelity_parser_errors.ml
hphp/hack/src/parser/full_fidelity_syntax_error.ml
hphp/hack/src/parser/full_fidelity_syntax_error.mli
hphp/hack/src/typing/nastCheck.ml
hphp/hack/src/typing/pp_type.ml
hphp/hack/src/typing/typing.ml
hphp/hack/src/typing/typing_defs.ml
hphp/hack/src/typing/typing_mutability.ml
hphp/hack/src/typing/typing_mutability.mli
hphp/hack/src/typing/typing_subtype.ml
hphp/hack/test/errors/error_map.ml
hphp/hack/test/tast/pseudofunctions.php
hphp/hack/test/tast/pseudofunctions.php.exp
hphp/hack/test/typecheck/reactive/mutable_or_immutable4.php.exp
hphp/hack/test/typecheck/reactive/mutable_or_immutable8.php
hphp/hack/test/typecheck/reactive/mutable_or_immutable9.php
hphp/hack/test/typecheck/reactive/owned_mutable1.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable1.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable10.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable10.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable11.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable11.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable12.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable12.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable13.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable13.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable15.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable15.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable2.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable2.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable3.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable3.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable4.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable4.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable5.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable5.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable6.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable6.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable7.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable7.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable8.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable8.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable9.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/owned_mutable9.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move1.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move1.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move2.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move2.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move3.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move3.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move4.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move4.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move5.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move5.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move6.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move6.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move7.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_move7.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_mutable3.php
hphp/hack/test/typecheck/reactive/rx_mutable3.php.exp
hphp/hack/test/typecheck/reactive/rx_mutable9.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/rx_mutable9.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_freeze1.php
hphp/hack/test/typecheck/reactive/test_freeze1.php.exp
hphp/hack/test/typecheck/reactive/test_freeze2.php
hphp/hack/test/typecheck/reactive/test_freeze3.php
hphp/hack/test/typecheck/reactive/test_freeze3.php.exp
hphp/hack/test/typecheck/reactive/test_method_call.php
hphp/hack/test/typecheck/reactive/test_method_call.php.exp
hphp/hack/test/typecheck/reactive/test_mutable_arg1.php
hphp/hack/test/typecheck/reactive/test_mutable_arg2.php
hphp/hack/test/typecheck/reactive/test_mutable_arg2.php.exp
hphp/hack/test/typecheck/reactive/test_mutable_args3.php
hphp/hack/test/typecheck/reactive/test_mutable_args3.php.exp
hphp/hack/test/typecheck/reactive/test_mutable_params2.php
hphp/hack/test/typecheck/reactive/test_mutable_params2.php.exp
hphp/hack/test/typecheck/reactive/test_mutable_return2.php
hphp/hack/test/typecheck/reactive/test_mutable_return5.php
hphp/hack/test/typecheck/reactive/test_mutable_return5_1.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_1.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_2.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_2.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_3.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_3.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_4.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_4.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_5.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_5.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_6.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_6.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_7.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_7.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_8.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return5_8.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_mutable_return6.php.exp
hphp/hack/test/typecheck/reactive/test_mutable_return7.php
hphp/hack/test/typecheck/reactive/test_mutable_return7.php.exp
hphp/hack/test/typecheck/reactive/test_mutable_return8.php.exp
hphp/hack/test/typecheck/reactive/test_mutable_return9.php.exp