Skip to content

Commit

Permalink
remove zoned_with
Browse files Browse the repository at this point in the history
Summary:
This never saw any use, confirmed with the DEIC folks and Hack lang folks that it is safe to remove.

HIP: https://fb.workplace.com/groups/hacklang.design/posts/7909763912448812

Reviewed By: vassilmladenov

Differential Revision: D60698038

fbshipit-source-id: 7888a1efe63ca9e9a102767a07db5fc2313a9060
  • Loading branch information
Max Trivedi authored and facebook-github-bot committed Sep 13, 2024
1 parent 295d0f6 commit 42b37a5
Show file tree
Hide file tree
Showing 52 changed files with 149 additions and 552 deletions.
2 changes: 1 addition & 1 deletion hphp/hack/doc/HIPs/memoization_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function some_recursive_callee_of_do_stuff()[zoned]: void {

In order to prevent poisoning memoization caches (fetching the cached results computed under one IC value when executing under a different IC value), we designed the IC feature to be coupled with the coeffects feature which applies static recursive restrictions. We required that:

* You can only set an IC for the execution of functions requiring at most `[zoned]` (or `[zoned_with<T>]` but we ignore this context in this document)
* You can only set an IC for the execution of functions requiring at most `[zoned]` but we ignore this context in this document)
* Memoized functions that are callable from a `[zoned]` function must either:
* shard the memoization cache based on the IC value (iff the context of the function is `[zoned]`)
* guarantee that the IC is not used by having a context without the `ImplicitPolicy` capability which is required to access the IC (e.g. `[leak_safe]`)
Expand Down
31 changes: 4 additions & 27 deletions hphp/hack/hhi/coeffect/contexts.hhi
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ namespace HH\Contexts {
*
* `defaults` functions may call into `zoned` functions, but not the
* other way around.
*
* `defaults` also excludes the capabilities required to call (or be called
* from) `zoned_with` functions.
*/
type defaults = (
\HH\Capabilities\WriteProperty &
Expand Down Expand Up @@ -130,8 +127,7 @@ namespace HH\Contexts {
* as `leak_safe` for internal operations (e.g. no mutating static
* variables). They are also allowed to call `leak_safe_local` or
* `leak_safe_shallow` functions and their leak-safe counterparts,
* and even `defaults` functions. However, they cannot call
* functions with the `zoned_with` context nor its shallow/local variant.
* and even `defaults` functions.
*/
type leak_safe_local = (
\HH\Capabilities\WriteProperty &
Expand All @@ -143,9 +139,8 @@ namespace HH\Contexts {
* `zoned` includes all the capabilities of `leak_safe`, but also allows
* accessing the current zone policy.
*
* `zoned` functions may be called from either `defaults` functions or
* `zoned_with` functions. `zoned` is more restrictive, so it cannot call
* into `defaults` or `zoned_with` functions.
* `zoned` functions may be called from `defaults` functions.
* `zoned` is more restrictive, so it cannot call into `defaults` functions.
*/
type zoned = (
\HH\Capabilities\WriteProperty &
Expand Down Expand Up @@ -180,8 +175,7 @@ namespace HH\Contexts {
* as `zoned` for internal operations (e.g. no mutating static
* variables). They are also allowed to call `zoned_local` or
* `zoned_shallow` functions and their leak-safe counterparts,
* and even `defaults` functions. Notably, they cannot call
* functions with the `zoned_with` context nor its shallow/local variant.
* and even `defaults` functions.
*/
type zoned_local = (
\HH\Capabilities\WriteProperty &
Expand All @@ -190,23 +184,6 @@ namespace HH\Contexts {
\HH\Capabilities\SystemLocal &
);

/**
* The `zoned_with<Foo>` context allows your function to be used with
* other `zoned_with<Foo>` functions.
*
* This is similar to `zoned`, but allows you define multiple distinct
* zones.
*
* `zoned_with` functions require a special entry point, and cannot be
* called from `defaults` functions.
*/
type zoned_with<T> = (
\HH\Capabilities\WriteProperty &
\HH\Capabilities\ReadGlobals &
\HH\Capabilities\ImplicitPolicyOf<T> &
\HH\Capabilities\System &
);

/**
* The `read_globals` context gives your function the capability to read
* global state, such as static properties on classes.
Expand Down
1 change: 0 additions & 1 deletion hphp/hack/hhi/coeffect/unsafe_contexts.hhi
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ namespace HH\Contexts\Unsafe {
type zoned_shallow =
(\HH\Capabilities\ImplicitPolicyLocal & \HH\Capabilities\SystemLocal &);
type zoned_local = \HH\Contexts\defaults;
type zoned_with<T> = mixed;

type rx = \HH\Contexts\defaults;
type rx_shallow = \HH\Contexts\defaults;
Expand Down
7 changes: 3 additions & 4 deletions hphp/hack/src/hackc/assemble/assemble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,9 @@ fn assemble_class(token_iter: &mut Lexer<'_>, adata: &AdataMap) -> Result<hhbc::
/// Defined in 'hack/src/naming/naming_special_names.rs`
fn is_enforced_static_coeffect(d: &str) -> bool {
match d {
"pure" | "defaults" | "rx" | "zoned" | "write_props" | "rx_local" | "zoned_with"
| "zoned_local" | "zoned_shallow" | "leak_safe_local" | "leak_safe_shallow"
| "leak_safe" | "read_globals" | "globals" | "write_this_props" | "rx_shallow" => true,
"pure" | "defaults" | "rx" | "zoned" | "write_props" | "rx_local" | "zoned_local"
| "zoned_shallow" | "leak_safe_local" | "leak_safe_shallow" | "leak_safe"
| "read_globals" | "globals" | "write_this_props" | "rx_shallow" => true,
_ => false,
}
}
Expand Down Expand Up @@ -1533,7 +1533,6 @@ fn assemble_static_coeffects(
b"zoned" => scs.push(Ctx::Zoned),
b"write_props" => scs.push(Ctx::WriteProps),
b"rx_local" => scs.push(Ctx::RxLocal),
b"zoned_with" => scs.push(Ctx::ZonedWith),
b"zoned_local" => scs.push(Ctx::ZonedLocal),
b"zoned_shallow" => scs.push(Ctx::ZonedShallow),
b"leak_safe_local" => scs.push(Ctx::LeakSafeLocal),
Expand Down
1 change: 0 additions & 1 deletion hphp/hack/src/hackc/hhbc/coeffects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ impl Coeffects {
c::RX => Some(Ctx::Rx),
c::WRITE_THIS_PROPS => Some(Ctx::WriteThisProps),
c::WRITE_PROPS => Some(Ctx::WriteProps),
c::ZONED_WITH => Some(Ctx::ZonedWith),
c::ZONED_LOCAL => Some(Ctx::ZonedLocal),
c::ZONED_SHALLOW => Some(Ctx::ZonedShallow),
c::ZONED => Some(Ctx::Zoned),
Expand Down
14 changes: 3 additions & 11 deletions hphp/hack/src/naming/naming_special_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,6 @@ pub mod coeffects {

pub const ZONED: &str = "zoned";

pub const ZONED_WITH: &str = "zoned_with";

pub const PURE: &str = "pure";

pub const READ_GLOBALS: &str = "read_globals";
Expand All @@ -871,16 +869,15 @@ pub mod coeffects {

pub fn is_any_zoned(x: &str) -> bool {
lazy_static! {
static ref ZONED_SET: HashSet<&'static str> =
vec![ZONED, ZONED_WITH].into_iter().collect();
static ref ZONED_SET: HashSet<&'static str> = vec![ZONED].into_iter().collect();
}
ZONED_SET.contains(x)
}

pub fn is_any_zoned_or_defaults(x: &str) -> bool {
lazy_static! {
static ref ZONED_SET: HashSet<&'static str> =
vec![ZONED, ZONED_WITH, ZONED_LOCAL, ZONED_SHALLOW, DEFAULTS]
vec![ZONED, ZONED_LOCAL, ZONED_SHALLOW, DEFAULTS]
.into_iter()
.collect();
}
Expand Down Expand Up @@ -913,7 +910,6 @@ pub mod coeffects {
Rx,

// Zoned hierarchy
ZonedWith,
ZonedLocal,
ZonedShallow,
Zoned,
Expand All @@ -940,7 +936,6 @@ pub mod coeffects {
Rx => write!(f, "{}", RX),
WriteThisProps => write!(f, "{}", WRITE_THIS_PROPS),
WriteProps => write!(f, "{}", WRITE_PROPS),
ZonedWith => write!(f, "{}", ZONED_WITH),
ZonedLocal => write!(f, "{}", ZONED_LOCAL),
ZonedShallow => write!(f, "{}", ZONED_SHALLOW),
Zoned => write!(f, "{}", ZONED),
Expand All @@ -964,7 +959,6 @@ pub mod coeffects {
RX => Some(Ctx::Rx),
WRITE_THIS_PROPS => Some(Ctx::WriteThisProps),
WRITE_PROPS => Some(Ctx::WriteProps),
ZONED_WITH => Some(Ctx::ZonedWith),
ZONED_LOCAL => Some(Ctx::ZonedLocal),
ZONED_SHALLOW => Some(Ctx::ZonedShallow),
ZONED => Some(Ctx::Zoned),
Expand Down Expand Up @@ -996,9 +990,7 @@ pub mod coeffects {
Ctx::LeakSafe | Ctx::LeakSafeLocal | Ctx::LeakSafeShallow => {
self::capability_in_controlled_ctx(c)
}
Ctx::Zoned | Ctx::ZonedLocal | Ctx::ZonedShallow | Ctx::ZonedWith => {
self::capability_in_policied_ctx(c)
}
Ctx::Zoned | Ctx::ZonedLocal | Ctx::ZonedShallow => self::capability_in_policied_ctx(c),
// By definition, granular capabilities are not contexts and cannot
// contain other capabilities. Also included in the fall through here
// are pure, namespaced, polymorphic, and encapsulated contexts; oldrx related
Expand Down
2 changes: 1 addition & 1 deletion hphp/hack/src/parser/lowerer/lowerer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5517,7 +5517,7 @@ fn check_effect_memoized<'a>(
)
}
}
// memoized functions with zoned or zoned_with must be #KeyedByIC
// memoized functions with zoned must be #KeyedByIC
if has_any_policied_context(contexts) {
if let Some(u) = user_attributes
.iter()
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion hphp/hack/test/typecheck/coeffects/as.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class C {
const ctx C1 = [];
const ctx C2 = [write_props];
const ctx C3 = [defaults, cipp];
const ctx C3 = [defaults];

public function f(): void {
3 as this::C1;
Expand Down
10 changes: 4 additions & 6 deletions hphp/hack/test/typecheck/coeffects/as.php.exp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
ERROR: File "as.php", line 6, characters 29-32:
Unbound name: `HH\Contexts\cipp` (Naming[2049])
ERROR: File "as.php", line 9, characters 10-17:
Invalid `as` expression hint (Typing[4195])
File "as.php", line 4, characters 18-19:
Expand All @@ -10,7 +8,7 @@ Invalid `as` expression hint (Typing[4195])
The `as` operator cannot be used with an intersection type, which is restricted to coeffects
ERROR: File "as.php", line 11, characters 10-17:
Invalid `as` expression hint (Typing[4195])
File "as.php", line 6, characters 18-33:
File "as.php", line 6, characters 18-27:
The `as` operator cannot be used with an intersection type, which is restricted to coeffects
ERROR: File "as.php", line 22, characters 8-12:
Invalid `as` expression hint (Typing[4195])
Expand All @@ -22,7 +20,7 @@ Invalid `as` expression hint (Typing[4195])
The `as` operator cannot be used with an intersection type, which is restricted to coeffects
ERROR: File "as.php", line 24, characters 8-12:
Invalid `as` expression hint (Typing[4195])
File "as.php", line 6, characters 18-33:
File "as.php", line 6, characters 18-27:
The `as` operator cannot be used with an intersection type, which is restricted to coeffects
ERROR: File "as.php", line 15, characters 9-16:
Invalid type (Typing[4302])
Expand All @@ -40,7 +38,7 @@ ERROR: File "as.php", line 17, characters 9-16:
Invalid type (Typing[4302])
File "as.php", line 27, characters 38-38:
Type parameter `T` was declared `__Enforceable` here
File "as.php", line 6, characters 18-33:
File "as.php", line 6, characters 18-27:
This type is not enforceable because it has an intersection type, which is restricted to coeffects
ERROR: File "as.php", line 32, characters 7-11:
Invalid type (Typing[4302])
Expand All @@ -58,7 +56,7 @@ ERROR: File "as.php", line 34, characters 7-11:
Invalid type (Typing[4302])
File "as.php", line 27, characters 38-38:
Type parameter `T` was declared `__Enforceable` here
File "as.php", line 6, characters 18-33:
File "as.php", line 6, characters 18-27:
This type is not enforceable because it has an intersection type, which is restricted to coeffects
WARN: File "as.php", line 9, characters 5-17:
This `as` assertion will always succeed and hence is redundant. The expression on the left has a type `int` which is a subtype of `mixed`. (Warn[12011])
Expand Down
10 changes: 4 additions & 6 deletions hphp/hack/test/typecheck/coeffects/as.php.imp_pess_exp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
ERROR: File "as.php", line 6, characters 29-32:
Unbound name: `HH\Contexts\cipp` (Naming[2049])
ERROR: File "as.php", line 9, characters 10-17:
Invalid `as` expression hint (Typing[4195])
File "as.php", line 4, characters 18-19:
Expand All @@ -10,7 +8,7 @@ Invalid `as` expression hint (Typing[4195])
The `as` operator cannot be used with an intersection type, which is restricted to coeffects
ERROR: File "as.php", line 11, characters 10-17:
Invalid `as` expression hint (Typing[4195])
File "as.php", line 6, characters 18-33:
File "as.php", line 6, characters 18-27:
The `as` operator cannot be used with an intersection type, which is restricted to coeffects
ERROR: File "as.php", line 22, characters 8-12:
Invalid `as` expression hint (Typing[4195])
Expand All @@ -22,7 +20,7 @@ Invalid `as` expression hint (Typing[4195])
The `as` operator cannot be used with an intersection type, which is restricted to coeffects
ERROR: File "as.php", line 24, characters 8-12:
Invalid `as` expression hint (Typing[4195])
File "as.php", line 6, characters 18-33:
File "as.php", line 6, characters 18-27:
The `as` operator cannot be used with an intersection type, which is restricted to coeffects
ERROR: File "as.php", line 15, characters 9-16:
Invalid type (Typing[4302])
Expand All @@ -40,7 +38,7 @@ ERROR: File "as.php", line 17, characters 9-16:
Invalid type (Typing[4302])
File "as.php", line 27, characters 38-38:
Type parameter `T` was declared `__Enforceable` here
File "as.php", line 6, characters 18-33:
File "as.php", line 6, characters 18-27:
This type is not enforceable because it has an intersection type, which is restricted to coeffects
ERROR: File "as.php", line 32, characters 7-11:
Invalid type (Typing[4302])
Expand All @@ -58,7 +56,7 @@ ERROR: File "as.php", line 34, characters 7-11:
Invalid type (Typing[4302])
File "as.php", line 27, characters 38-38:
Type parameter `T` was declared `__Enforceable` here
File "as.php", line 6, characters 18-33:
File "as.php", line 6, characters 18-27:
This type is not enforceable because it has an intersection type, which is restricted to coeffects
ERROR: File "as.php", line 15, characters 5-7:
Some type arguments violate their constraints (Typing[4323])
Expand Down
30 changes: 8 additions & 22 deletions hphp/hack/test/typecheck/coeffects/cipp.php.exp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
ERROR: File "cipp.php", line 27, characters 28-37:
Unbound name: `HH\Contexts\Unsafe\zoned_with` (Naming[2049])
ERROR: File "cipp.php", line 27, characters 28-37:
Unbound name: `HH\Contexts\zoned_with` (Naming[2049])
ERROR: File "cipp.php", line 6, characters 3-22:
This call is not allowed because its capabilities are incompatible with the context (Typing[4390])
File "cipp.php", line 5, characters 25-29:
Expand All @@ -15,7 +19,7 @@ This call is not allowed because its capabilities are incompatible with the cont
File "cipp.php", line 5, characters 25-29:
From this declaration, the context of this function body provides the capability set {ImplicitPolicy, ReadGlobals, System, WriteProperty}
File "cipp.php", line 27, characters 28-40:
But the function being called requires the capability set {ImplicitPolicyOf<A>, ReadGlobals, System, WriteProperty}
But the function being called requires the capability zoned_with<A>
ERROR: File "cipp.php", line 9, characters 3-10:
This call is not allowed because its capabilities are incompatible with the context (Typing[4390])
File "cipp.php", line 5, characters 25-29:
Expand All @@ -27,7 +31,7 @@ This call is not allowed because its capabilities are incompatible with the cont
File "cipp.php", line 12, characters 33-45:
From this declaration, the context of this function body provides the capability set {ImplicitPolicyLocal, ReadGlobals, SystemLocal, WriteProperty}
File "cipp.php", line 27, characters 28-40:
But the function being called requires the capability set {ImplicitPolicyOf<A>, ReadGlobals, System, WriteProperty}
But the function being called requires the capability zoned_with<A>
ERROR: File "cipp.php", line 16, characters 3-10:
This call is not allowed because its capabilities are incompatible with the context (Typing[4390])
File "cipp.php", line 12, characters 33-45:
Expand All @@ -39,28 +43,10 @@ This call is not allowed because its capabilities are incompatible with the cont
File "cipp.php", line 19, characters 31-41:
From this declaration, the context of this function body provides the capability set {AccessGlobals, IO, ImplicitPolicyLocal, RxLocal, SystemLocal, WriteProperty}
File "cipp.php", line 27, characters 28-40:
But the function being called requires the capability set {ImplicitPolicyOf<A>, ReadGlobals, System, WriteProperty}
ERROR: File "cipp.php", line 29, characters 3-22:
This call is not allowed because its capabilities are incompatible with the context (Typing[4390])
File "cipp.php", line 27, characters 28-40:
From this declaration, the context of this function body provides the capability set {ImplicitPolicyOf<A>, ReadGlobals, System, WriteProperty}
File "cipp.php", line 12, characters 33-45:
But the function being called requires the capability set {ImplicitPolicyShallow, ReadGlobals, SystemShallow, WriteProperty}
ERROR: File "cipp.php", line 30, characters 3-20:
This call is not allowed because its capabilities are incompatible with the context (Typing[4390])
File "cipp.php", line 27, characters 28-40:
From this declaration, the context of this function body provides the capability set {ImplicitPolicyOf<A>, ReadGlobals, System, WriteProperty}
File "cipp.php", line 19, characters 31-41:
But the function being called requires the capability set {ImplicitPolicyLocal, ReadGlobals, SystemLocal, WriteProperty}
ERROR: File "cipp.php", line 31, characters 3-10:
This call is not allowed because its capabilities are incompatible with the context (Typing[4390])
File "cipp.php", line 27, characters 28-40:
From this declaration, the context of this function body provides the capability set {ImplicitPolicyOf<A>, ReadGlobals, System, WriteProperty}
File "cipp.php", line 34, characters 10-17:
But the function being called requires the capability set {AccessGlobals, IO, ImplicitPolicyLocal, RxLocal, SystemLocal, WriteProperty}
But the function being called requires the capability zoned_with<A>
ERROR: File "cipp.php", line 39, characters 3-17:
This call is not allowed because its capabilities are incompatible with the context (Typing[4390])
File "cipp.php", line 34, characters 10-17:
From this declaration, the context of this function body provides the capability set {AccessGlobals, IO, ImplicitPolicyLocal, RxLocal, SystemLocal, WriteProperty}
File "cipp.php", line 27, characters 28-40:
But the function being called requires the capability set {ImplicitPolicyOf<A>, ReadGlobals, System, WriteProperty}
But the function being called requires the capability zoned_with<A>
Loading

0 comments on commit 42b37a5

Please sign in to comment.