Skip to content

Commit 19d2b51

Browse files
stepanchegfacebook-github-bot
authored andcommitted
ExprCompiledValue::Type ExprCompiledValue
Summary: Change `ExprCompileValue` `Type` variant to hold `ExprCompiledValue` instead of `ExprCompiled` so we could inspect an argument of `type(x)` call in the following diff D30888373. Reviewed By: ndmitchell Differential Revision: D30888374 fbshipit-source-id: 2cdddbda1b72bb979da17a561f4ed88cf59d2407
1 parent 87780d3 commit 19d2b51

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

starlark/src/eval/fragment/expr.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub(crate) enum ExprCompiledValue {
5050
Value(FrozenValue),
5151
Compiled(ExprCompiled),
5252
/// `type(x)`
53-
Type(ExprCompiled),
53+
Type(Box<ExprCompiledValue>),
5454
}
5555

5656
impl ExprCompiledValue {
@@ -65,8 +65,8 @@ impl ExprCompiledValue {
6565
match self {
6666
Self::Value(x) => box move |_| Ok(x.to_value()),
6767
Self::Compiled(x) => x,
68-
Self::Type(x) => expr!("type", |eval| {
69-
x(eval)?.get_ref().get_type_value().to_value()
68+
Self::Type(x) => expr!("type", x, |_eval| {
69+
x.get_ref().get_type_value().to_value()
7070
})
7171
.as_compiled(),
7272
}
@@ -107,7 +107,6 @@ fn try_eval_type_is(
107107
match (l, r) {
108108
(ExprCompiledValue::Type(l), ExprCompiledValue::Value(r)) => {
109109
if let Some(r) = r.downcast_frozen_ref::<StarlarkStr>() {
110-
let l = ExprCompiledValue::Compiled(l);
111110
let t = r.map(|r| r.unpack());
112111
Ok(expr!("type_is", l, |_eval| {
113112
Value::new_bool(cmp(l.get_type() == t.as_ref()))

starlark/src/eval/fragment/known.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl Compiler<'_> {
9898
}
9999
match self.expr(expr) {
100100
ExprCompiledValue::Value(x) => ExprCompiledValue::Value(x.to_value().get_type_value()),
101-
x => ExprCompiledValue::Type(x.as_compiled()),
101+
x => ExprCompiledValue::Type(box x),
102102
}
103103
}
104104
}

0 commit comments

Comments
 (0)