Remove expect-fx syntax and handling

This was never fully hooked up in platforms, and the plan is to replace the need for this with doing purity-inference on normal `expect` statements.

On the other hand, fuzzing is finding some bugs caused by having a hyphenated keyword, so this is a great time to go ahead and remove it!
This commit is contained in:
Joshua Warner 2024-11-17 20:24:09 -08:00
parent 7bf3701c9e
commit 9ead801536
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
32 changed files with 21 additions and 641 deletions

View file

@ -616,7 +616,6 @@ fn stmt_spec<'a>(
}
Dbg { remainder, .. } => stmt_spec(builder, interner, env, block, layout, remainder),
Expect { remainder, .. } => stmt_spec(builder, interner, env, block, layout, remainder),
ExpectFx { remainder, .. } => stmt_spec(builder, interner, env, block, layout, remainder),
Ret(symbol) => Ok(env.symbols[symbol]),
Refcounting(modify_rc, continuation) => {
apply_refcount_operation(builder, env, block, modify_rc)?;

View file

@ -694,16 +694,6 @@ fn deep_copy_expr_help<C: CopyEnv>(env: &mut C, copied: &mut Vec<Variable>, expr
lookups_in_cond: lookups_in_cond.to_vec(),
},
ExpectFx {
loc_condition,
loc_continuation,
lookups_in_cond,
} => ExpectFx {
loc_condition: Box::new(loc_condition.map(|e| go_help!(e))),
loc_continuation: Box::new(loc_continuation.map(|e| go_help!(e))),
lookups_in_cond: lookups_in_cond.to_vec(),
},
Return {
return_value,
return_var,

View file

@ -453,7 +453,6 @@ fn expr<'a>(c: &Ctx, p: EPrec, f: &'a Arena<'a>, e: &'a Expr) -> DocBuilder<'a,
),
Dbg { .. } => todo!(),
Expect { .. } => todo!(),
ExpectFx { .. } => todo!(),
Return { .. } => todo!(),
TypedHole(_) => todo!(),
RuntimeError(_) => todo!(),

View file

@ -171,7 +171,6 @@ pub(crate) struct CanDefs {
defs: Vec<Option<Def>>,
dbgs: ExpectsOrDbgs,
expects: ExpectsOrDbgs,
expects_fx: ExpectsOrDbgs,
def_ordering: DefOrdering,
aliases: VecMap<Symbol, Alias>,
}
@ -1170,7 +1169,6 @@ fn canonicalize_value_defs<'a>(
let mut pending_value_defs = Vec::with_capacity(value_defs.len());
let mut pending_dbgs = Vec::with_capacity(value_defs.len());
let mut pending_expects = Vec::with_capacity(value_defs.len());
let mut pending_expect_fx = Vec::with_capacity(value_defs.len());
let mut imports_introduced = Vec::with_capacity(value_defs.len());
@ -1190,9 +1188,6 @@ fn canonicalize_value_defs<'a>(
PendingValue::Expect(pending_expect) => {
pending_expects.push(pending_expect);
}
PendingValue::ExpectFx(pending_expect) => {
pending_expect_fx.push(pending_expect);
}
PendingValue::ModuleImport(PendingModuleImport {
module_id,
region,
@ -1278,7 +1273,6 @@ fn canonicalize_value_defs<'a>(
let mut dbgs = ExpectsOrDbgs::with_capacity(pending_dbgs.len());
let mut expects = ExpectsOrDbgs::with_capacity(pending_expects.len());
let mut expects_fx = ExpectsOrDbgs::with_capacity(pending_expects.len());
for pending in pending_dbgs {
let (loc_can_condition, can_output) = canonicalize_expr(
@ -1308,25 +1302,10 @@ fn canonicalize_value_defs<'a>(
output.union(can_output);
}
for pending in pending_expect_fx {
let (loc_can_condition, can_output) = canonicalize_expr(
env,
var_store,
scope,
pending.condition.region,
&pending.condition.value,
);
expects_fx.push(loc_can_condition, pending.preceding_comment);
output.union(can_output);
}
let can_defs = CanDefs {
defs,
dbgs,
expects,
expects_fx,
def_ordering,
aliases,
};
@ -1734,7 +1713,6 @@ pub(crate) fn sort_top_level_can_defs(
defs,
dbgs: _,
expects,
expects_fx,
def_ordering,
aliases,
} = defs;
@ -1765,19 +1743,6 @@ pub(crate) fn sort_top_level_can_defs(
declarations.push_expect(preceding_comment, name, Loc::at(region, condition));
}
let it = expects_fx
.conditions
.into_iter()
.zip(expects_fx.regions)
.zip(expects_fx.preceding_comment);
for ((condition, region), preceding_comment) in it {
// an `expect` does not have a user-defined name, but we'll need a name to call the expectation
let name = scope.gen_unique_symbol();
declarations.push_expect_fx(preceding_comment, name, Loc::at(region, condition));
}
for (symbol, alias) in aliases.into_iter() {
output.aliases.insert(symbol, alias);
}
@ -2015,7 +1980,6 @@ pub(crate) fn sort_can_defs(
mut defs,
dbgs,
expects,
expects_fx,
def_ordering,
aliases,
} = defs;
@ -2149,10 +2113,6 @@ pub(crate) fn sort_can_defs(
declarations.push(Declaration::Expects(expects));
}
if !expects_fx.conditions.is_empty() {
declarations.push(Declaration::ExpectsFx(expects_fx));
}
(declarations, output)
}
@ -3078,7 +3038,6 @@ enum PendingValue<'a> {
Def(PendingValueDef<'a>),
Dbg(PendingExpectOrDbg<'a>),
Expect(PendingExpectOrDbg<'a>),
ExpectFx(PendingExpectOrDbg<'a>),
ModuleImport(PendingModuleImport<'a>),
SignatureDefMismatch,
InvalidIngestedFile,
@ -3218,14 +3177,6 @@ fn to_pending_value_def<'a>(
preceding_comment: *preceding_comment,
}),
ExpectFx {
condition,
preceding_comment,
} => PendingValue::ExpectFx(PendingExpectOrDbg {
condition,
preceding_comment: *preceding_comment,
}),
ModuleImport(module_import) => {
let qualified_module_name: QualifiedModuleName = module_import.name.value.into();
let module_name = qualified_module_name.module.clone();

View file

@ -167,16 +167,6 @@ fn desugar_value_def<'a>(
preceding_comment: *preceding_comment,
}
}
ExpectFx {
condition,
preceding_comment,
} => {
let desugared_condition = &*env.arena.alloc(desugar_expr(env, scope, condition));
ExpectFx {
condition: desugared_condition,
preceding_comment: *preceding_comment,
}
}
ModuleImport(roc_parse::ast::ModuleImport {
before_name,
name,
@ -380,8 +370,8 @@ pub fn desugar_value_def_suffixed<'a>(arena: &'a Bump, value_def: ValueDef<'a>)
}
},
// TODO support desugaring of Dbg and ExpectFx
Dbg { .. } | ExpectFx { .. } => value_def,
// TODO support desugaring of Dbg
Dbg { .. } => value_def,
ModuleImport { .. } | IngestedFileImport(_) | StmtAfterExpr => value_def,
Stmt(..) => {

View file

@ -271,13 +271,6 @@ pub enum Expr {
lookups_in_cond: Vec<ExpectLookup>,
},
// not parsed, but is generated when lowering toplevel effectful expects
ExpectFx {
loc_condition: Box<Loc<Expr>>,
loc_continuation: Box<Loc<Expr>>,
lookups_in_cond: Vec<ExpectLookup>,
},
Dbg {
source_location: Box<str>,
source: Box<str>,
@ -364,7 +357,6 @@ impl Expr {
Category::OpaqueWrap(opaque_name)
}
Self::Expect { .. } => Category::Expect,
Self::ExpectFx { .. } => Category::Expect,
Self::Crash { .. } => Category::Crash,
Self::Return { .. } => Category::Return,
@ -2217,28 +2209,6 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
}
}
ExpectFx {
loc_condition,
loc_continuation,
lookups_in_cond,
} => {
let loc_condition = Loc {
region: loc_condition.region,
value: inline_calls(var_store, loc_condition.value),
};
let loc_continuation = Loc {
region: loc_continuation.region,
value: inline_calls(var_store, loc_continuation.value),
};
ExpectFx {
loc_condition: Box::new(loc_condition),
loc_continuation: Box::new(loc_continuation),
lookups_in_cond,
}
}
Dbg {
source_location,
source,
@ -3019,24 +2989,6 @@ impl Declarations {
index
}
pub fn push_expect_fx(
&mut self,
preceding_comment: Region,
name: Symbol,
loc_expr: Loc<Expr>,
) -> usize {
let index = self.declarations.len();
self.declarations.push(DeclarationTag::ExpectationFx);
self.variables.push(Variable::BOOL);
self.symbols.push(Loc::at(preceding_comment, name));
self.annotations.push(None);
self.expressions.push(loc_expr);
index
}
pub fn push_value_def(
&mut self,
symbol: Loc<Symbol>,
@ -3477,9 +3429,6 @@ pub(crate) fn get_lookup_symbols(expr: &Expr) -> Vec<ExpectLookup> {
Expr::Expect {
loc_continuation, ..
}
| Expr::ExpectFx {
loc_continuation, ..
}
| Expr::Dbg {
loc_continuation, ..
} => {
@ -3581,18 +3530,11 @@ fn toplevel_expect_to_inline_expect_help(mut loc_expr: Loc<Expr>, has_effects: b
}
let expect_region = loc_expr.region;
let expect = if has_effects {
Expr::ExpectFx {
loc_condition: Box::new(loc_expr),
loc_continuation: Box::new(Loc::at_zero(Expr::EmptyRecord)),
lookups_in_cond,
}
} else {
Expr::Expect {
loc_condition: Box::new(loc_expr),
loc_continuation: Box::new(Loc::at_zero(Expr::EmptyRecord)),
lookups_in_cond,
}
assert!(!has_effects);
let expect = Expr::Expect {
loc_condition: Box::new(loc_expr),
loc_continuation: Box::new(Loc::at_zero(Expr::EmptyRecord)),
lookups_in_cond,
};
let mut loc_expr = Loc::at(expect_region, expect);
@ -3624,11 +3566,6 @@ impl crate::traverse::Visitor for ExpectCollector {
lookups_in_cond,
loc_condition,
..
}
| Expr::ExpectFx {
lookups_in_cond,
loc_condition,
..
} => {
self.expects
.insert(loc_condition.region, lookups_in_cond.to_vec());

View file

@ -956,11 +956,6 @@ fn fix_values_captured_in_closure_expr(
loc_continuation,
..
}
| ExpectFx {
loc_condition,
loc_continuation,
..
}
| Dbg {
loc_message: loc_condition,
loc_continuation,

View file

@ -680,7 +680,7 @@ pub fn unwrap_suffixed_expression_defs_help<'a>(
};
let maybe_suffixed_value_def = match current_value_def {
Annotation(..) | Dbg{..} | Expect{..} | ExpectFx{..} | Stmt(..) | ModuleImport{..} | IngestedFileImport(_) => None,
Annotation(..) | Dbg{..} | Expect{..} | Stmt(..) | ModuleImport{..} | IngestedFileImport(_) => None,
AnnotatedBody { body_pattern, body_expr, ann_type, ann_pattern, .. } => Some((body_pattern, body_expr, Some((ann_pattern, ann_type)))),
Body (def_pattern, def_expr) => Some((def_pattern, def_expr, None)),
StmtAfterExpr => None,

View file

@ -385,18 +385,6 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expr: &Expr, var: Variable) {
Variable::NULL,
);
}
Expr::ExpectFx {
loc_condition,
loc_continuation,
lookups_in_cond: _,
} => {
visitor.visit_expr(&loc_condition.value, loc_condition.region, Variable::BOOL);
visitor.visit_expr(
&loc_continuation.value,
loc_continuation.region,
Variable::NULL,
);
}
Expr::Dbg {
variable,
source: _,

View file

@ -792,63 +792,6 @@ pub fn constrain_expr(
constraints.exists_many(vars, all_constraints)
}
ExpectFx {
loc_condition,
loc_continuation,
lookups_in_cond,
} => {
let expected_bool = {
let bool_type = constraints.push_variable(Variable::BOOL);
constraints.push_expected_type(Expected::ForReason(
Reason::ExpectCondition,
bool_type,
loc_condition.region,
))
};
let cond_con = constrain_expr(
types,
constraints,
env,
loc_condition.region,
&loc_condition.value,
expected_bool,
);
let continuation_con = constrain_expr(
types,
constraints,
env,
loc_continuation.region,
&loc_continuation.value,
expected,
);
// + 2 for cond_con and continuation_con
let mut all_constraints = Vec::with_capacity(lookups_in_cond.len() + 2);
all_constraints.push(cond_con);
all_constraints.push(continuation_con);
let mut vars = Vec::with_capacity(lookups_in_cond.len());
for ExpectLookup {
symbol,
var,
ability_info: _,
} in lookups_in_cond.iter()
{
vars.push(*var);
let var_index = constraints.push_variable(*var);
let store_into = constraints.push_expected_type(NoExpectation(var_index));
all_constraints.push(constraints.lookup(*symbol, store_into, Region::zero()));
}
constraints.exists_many(vars, all_constraints)
}
Dbg {
source_location: _,
source: _,
@ -4416,7 +4359,6 @@ fn is_generalizable_expr(mut expr: &Expr) -> bool {
| TupleAccess { .. }
| RecordUpdate { .. }
| Expect { .. }
| ExpectFx { .. }
| Dbg { .. }
| Return { .. }
| TypedHole(_)

View file

@ -419,7 +419,6 @@ impl<'a> Formattable for ValueDef<'a> {
Body(loc_pattern, loc_expr) => loc_pattern.is_multiline() || loc_expr.is_multiline(),
AnnotatedBody { .. } => true,
Expect { condition, .. } => condition.is_multiline(),
ExpectFx { condition, .. } => condition.is_multiline(),
Dbg { condition, .. } => condition.is_multiline(),
ModuleImport(module_import) => module_import.is_multiline(),
IngestedFileImport(ingested_file_import) => ingested_file_import.is_multiline(),
@ -446,9 +445,6 @@ impl<'a> Formattable for ValueDef<'a> {
}
Dbg { condition, .. } => fmt_dbg_in_def(buf, condition, self.is_multiline(), indent),
Expect { condition, .. } => fmt_expect(buf, condition, self.is_multiline(), indent),
ExpectFx { condition, .. } => {
fmt_expect_fx(buf, condition, self.is_multiline(), indent)
}
AnnotatedBody {
ann_pattern,
ann_type,
@ -557,22 +553,6 @@ fn fmt_expect<'a>(buf: &mut Buf, condition: &'a Loc<Expr<'a>>, is_multiline: boo
condition.format(buf, return_indent);
}
fn fmt_expect_fx<'a>(buf: &mut Buf, condition: &'a Loc<Expr<'a>>, is_multiline: bool, indent: u16) {
buf.ensure_ends_with_newline();
buf.indent(indent);
buf.push_str("expect-fx");
let return_indent = if is_multiline {
buf.newline();
indent + INDENT
} else {
buf.spaces(1);
indent
};
condition.format(buf, return_indent);
}
pub fn fmt_value_def(buf: &mut Buf, def: &roc_parse::ast::ValueDef, indent: u16) {
def.format(buf, indent);
}

View file

@ -279,7 +279,6 @@ impl<'a> LastSeenMap<'a> {
Stmt::Dbg { .. } => todo!("dbg not implemented in the dev backend"),
Stmt::Expect { .. } => todo!("expect is not implemented in the dev backend"),
Stmt::ExpectFx { .. } => todo!("expect-fx is not implemented in the dev backend"),
Stmt::Crash(msg, _crash_tag) => {
self.set_last_seen(*msg, stmt);

View file

@ -3650,74 +3650,6 @@ pub(crate) fn build_exp_stmt<'a, 'ctx>(
)
}
ExpectFx {
condition: cond_symbol,
region,
lookups,
variables,
remainder,
} => {
let bd = env.builder;
let context = env.context;
let (cond, _cond_layout) = scope.load_symbol_and_layout(cond_symbol);
let condition = bd.new_build_int_compare(
IntPredicate::EQ,
cond.into_int_value(),
context.bool_type().const_int(1, false),
"is_true",
);
let then_block = context.append_basic_block(parent, "then_block");
let throw_block = context.append_basic_block(parent, "throw_block");
bd.new_build_conditional_branch(condition, then_block, throw_block);
if env.mode.runs_expects() {
bd.position_at_end(throw_block);
match env.target.ptr_width() {
roc_target::PtrWidth::Bytes8 => {
let shared_memory = SharedMemoryPointer::get(env);
clone_to_shared_memory(
env,
layout_interner,
scope,
layout_ids,
&shared_memory,
*cond_symbol,
*region,
lookups,
variables,
);
bd.new_build_unconditional_branch(then_block);
}
roc_target::PtrWidth::Bytes4 => {
// temporary WASM implementation
throw_internal_exception(env, "An expectation failed!");
}
}
} else {
bd.position_at_end(throw_block);
bd.new_build_unconditional_branch(then_block);
}
bd.position_at_end(then_block);
build_exp_stmt(
env,
layout_interner,
layout_ids,
func_spec_solutions,
scope,
parent,
remainder,
)
}
Crash(sym, tag) => {
throw_exception(env, scope, sym, *tag);

View file

@ -607,7 +607,6 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
Stmt::Dbg { .. } => todo!("dbg is not implemented in the wasm backend"),
Stmt::Expect { .. } => todo!("expect is not implemented in the wasm backend"),
Stmt::ExpectFx { .. } => todo!("expect-fx is not implemented in the wasm backend"),
Stmt::Crash(sym, tag) => self.stmt_crash(*sym, *tag),
}

View file

@ -273,9 +273,6 @@ fn generate_entry_docs(
// Don't generate docs for `expect`s
}
ValueDef::ExpectFx { .. } => {
// Don't generate docs for `expect-fx`s
}
ValueDef::ModuleImport { .. } => {
// Don't generate docs for module imports
}

View file

@ -361,15 +361,6 @@ impl<'a> LowerParams<'a> {
expr_stack.push(&mut loc_condition.value);
expr_stack.push(&mut loc_continuation.value);
}
ExpectFx {
loc_condition,
loc_continuation,
lookups_in_cond: _,
} => {
expr_stack.reserve(2);
expr_stack.push(&mut loc_condition.value);
expr_stack.push(&mut loc_continuation.value);
}
Dbg {
loc_message,
loc_continuation,

View file

@ -306,7 +306,7 @@ impl<'state, 'a> State<'state, 'a> {
self.mark_owned(*s);
}
Stmt::Refcounting(_, _) => unreachable!("not inserted yet"),
Stmt::Expect { remainder, .. } | Stmt::ExpectFx { remainder, .. } => {
Stmt::Expect { remainder, .. } => {
// based on my reading of inc_dec.rs, expect borrows the symbols
self.inspect_stmt(interner, borrow_signatures, remainder);
}
@ -397,7 +397,7 @@ impl<'state, 'a> State<'state, 'a> {
"\n\tNo borrow signature for {name:?} layout.\n\n\t\
Tip 1: This can happen when you call a function with less arguments than it expects.\n\t\
Like `Arg.list!` instead of `Arg.list! {{}}`.\n\t\
Tip 2: `roc check yourfile.roc` can sometimes give you a helpful error.
Tip 2: `roc check yourfile.roc` can sometimes give you a helpful error.
"
)
};
@ -522,7 +522,6 @@ impl<'a> CallInfo<'a> {
Dbg { remainder, .. } => stack.push(remainder),
Expect { remainder, .. } => stack.push(remainder),
ExpectFx { remainder, .. } => stack.push(remainder),
Refcounting(_, _) => unreachable!("these have not been introduced yet"),

View file

@ -351,13 +351,6 @@ impl<'a, 'r> Ctx<'a, 'r> {
lookups,
variables: _,
remainder,
}
| &Stmt::ExpectFx {
condition,
region: _,
lookups,
variables: _,
remainder,
} => {
self.check_sym_layout(condition, Layout::BOOL, UseKind::ExpectCond);
for sym in lookups.iter() {

View file

@ -611,25 +611,6 @@ fn specialize_drops_stmt<'a, 'i>(
remainder,
),
}),
Stmt::ExpectFx {
condition,
region,
lookups,
variables,
remainder,
} => arena.alloc(Stmt::ExpectFx {
condition: *condition,
region: *region,
lookups,
variables,
remainder: specialize_drops_stmt(
arena,
layout_interner,
ident_ids,
environment,
remainder,
),
}),
Stmt::Dbg {
source_location,
source,

View file

@ -182,9 +182,7 @@ impl<'a, 'i> SymbolRcTypesEnv<'a, 'i> {
Stmt::Refcounting(_, _) => unreachable!(
"Refcounting operations should not be present in the AST at this point."
),
Stmt::Expect { remainder, .. }
| Stmt::ExpectFx { remainder, .. }
| Stmt::Dbg { remainder, .. } => {
Stmt::Expect { remainder, .. } | Stmt::Dbg { remainder, .. } => {
self.insert_symbols_rc_type_stmt(remainder);
}
Stmt::Join {
@ -680,30 +678,6 @@ fn insert_refcount_operations_stmt<'v, 'a>(
remainder: newer_remainder,
})
}
Stmt::ExpectFx {
condition,
region,
lookups,
variables,
remainder,
} => {
let new_remainder = insert_refcount_operations_stmt(arena, environment, remainder);
let newer_remainder = consume_and_insert_dec_stmts(
arena,
environment,
environment.borrowed_usages(lookups.iter().copied()),
new_remainder,
);
arena.alloc(Stmt::ExpectFx {
condition: *condition,
region: *region,
lookups,
variables,
remainder: newer_remainder,
})
}
Stmt::Dbg {
source_location,
source,

View file

@ -1531,14 +1531,6 @@ pub enum Stmt<'a> {
/// what happens after the expect
remainder: &'a Stmt<'a>,
},
ExpectFx {
condition: Symbol,
region: Region,
lookups: &'a [Symbol],
variables: &'a [LookupType],
/// what happens after the expect
remainder: &'a Stmt<'a>,
},
Dbg {
/// The location this dbg is in source as a printable string.
source_location: &'a str,
@ -2279,17 +2271,6 @@ impl<'a> Stmt<'a> {
.append(alloc.hardline())
.append(remainder.to_doc(alloc, interner, pretty)),
ExpectFx {
condition,
remainder,
..
} => alloc
.text("expect-fx ")
.append(symbol_to_doc(alloc, *condition, pretty))
.append(";")
.append(alloc.hardline())
.append(remainder.to_doc(alloc, interner, pretty)),
Ret(symbol) => alloc
.text("ret ")
.append(symbol_to_doc(alloc, *symbol, pretty))
@ -4645,7 +4626,6 @@ pub fn with_hole<'a>(
EmptyRecord => let_empty_struct(assigned, hole),
Expect { .. } => unreachable!("I think this is unreachable"),
ExpectFx { .. } => unreachable!("I think this is unreachable"),
Dbg {
source_location,
source,
@ -7118,73 +7098,6 @@ pub fn from_can<'a>(
stmt
}
ExpectFx {
loc_condition,
loc_continuation,
lookups_in_cond,
} => {
let rest = from_can(env, variable, loc_continuation.value, procs, layout_cache);
let cond_symbol = env.unique_symbol();
let mut lookups = Vec::with_capacity_in(lookups_in_cond.len(), env.arena);
let mut lookup_variables = Vec::with_capacity_in(lookups_in_cond.len(), env.arena);
let mut specialized_variables = Vec::with_capacity_in(lookups_in_cond.len(), env.arena);
for ExpectLookup {
symbol,
var,
ability_info,
} in lookups_in_cond.iter().copied()
{
let symbol = match ability_info {
Some(specialization_id) => late_resolve_ability_specialization(
env,
symbol,
Some(specialization_id),
var,
),
None => symbol,
};
let expectation_subs = env
.expectation_subs
.as_deref_mut()
.expect("if expects are compiled, their subs should be available");
let spec_var = expectation_subs.fresh_unnamed_flex_var();
if !env.subs.is_function(var) {
// Exclude functions from lookups
lookups.push(symbol);
lookup_variables.push(var);
specialized_variables.push(spec_var);
}
}
let specialized_variables = specialized_variables.into_bump_slice();
let mut stmt = Stmt::ExpectFx {
condition: cond_symbol,
region: loc_condition.region,
lookups: lookups.into_bump_slice(),
variables: specialized_variables,
remainder: env.arena.alloc(rest),
};
stmt = with_hole(
env,
loc_condition.value,
Variable::BOOL,
procs,
layout_cache,
cond_symbol,
env.arena.alloc(stmt),
);
store_specialized_expectation_lookups(env, lookup_variables, specialized_variables);
stmt
}
Dbg {
source_location,
source,
@ -7721,32 +7634,6 @@ fn substitute_in_stmt_help<'a>(
Some(arena.alloc(expect))
}
ExpectFx {
condition,
region,
lookups,
variables,
remainder,
} => {
let new_remainder =
substitute_in_stmt_help(arena, remainder, subs).unwrap_or(remainder);
let new_lookups = Vec::from_iter_in(
lookups.iter().map(|s| substitute(subs, *s).unwrap_or(*s)),
arena,
);
let expect = ExpectFx {
condition: substitute(subs, *condition).unwrap_or(*condition),
region: *region,
lookups: new_lookups.into_bump_slice(),
variables,
remainder: new_remainder,
};
Some(arena.alloc(expect))
}
Jump(id, args) => {
let mut did_change = false;
let new_args = Vec::from_iter_in(

View file

@ -625,31 +625,6 @@ fn insert_reset_reuse_operations_stmt<'a, 'i>(
remainder: new_remainder,
})
}
Stmt::ExpectFx {
condition,
region,
lookups,
variables,
remainder,
} => {
let new_remainder = insert_reset_reuse_operations_stmt(
arena,
layout_interner,
home,
ident_ids,
update_mode_ids,
environment,
remainder,
);
arena.alloc(Stmt::ExpectFx {
condition: *condition,
region: *region,
lookups,
variables,
remainder: new_remainder,
})
}
Stmt::Dbg {
source_location,
source,

View file

@ -377,30 +377,6 @@ fn insert_jumps<'a>(
None => None,
},
ExpectFx {
condition,
region,
lookups,
variables,
remainder,
} => match insert_jumps(
arena,
remainder,
goal_id,
needle,
needle_arguments,
needle_result,
) {
Some(cont) => Some(arena.alloc(ExpectFx {
condition: *condition,
region: *region,
lookups,
variables,
remainder: cont,
})),
None => None,
},
Ret(_) => None,
Jump(_, _) => None,
Crash(..) => None,
@ -551,9 +527,9 @@ fn trmc_candidates_help(
}
}
Stmt::Refcounting(_, next) => trmc_candidates_help(function_name, next, candidates),
Stmt::Expect { remainder, .. }
| Stmt::ExpectFx { remainder, .. }
| Stmt::Dbg { remainder, .. } => trmc_candidates_help(function_name, remainder, candidates),
Stmt::Expect { remainder, .. } | Stmt::Dbg { remainder, .. } => {
trmc_candidates_help(function_name, remainder, candidates)
}
Stmt::Join {
body, remainder, ..
} => {
@ -1010,19 +986,6 @@ impl<'a> TrmcEnv<'a> {
variables,
remainder: arena.alloc(self.walk_stmt(env, remainder)),
},
Stmt::ExpectFx {
condition,
region,
lookups,
variables,
remainder,
} => Stmt::Expect {
condition: *condition,
region: *region,
lookups,
variables,
remainder: arena.alloc(self.walk_stmt(env, remainder)),
},
Stmt::Dbg {
source_location,
source,
@ -1128,9 +1091,6 @@ fn stmt_contains_symbol_nonrec(stmt: &Stmt, needle: Symbol) -> bool {
}
Stmt::Expect {
condition, lookups, ..
}
| Stmt::ExpectFx {
condition, lookups, ..
} => needle == *condition || lookups.contains(&needle),
Stmt::Dbg { symbol, .. } => needle == *symbol,
Stmt::Join { .. } => false,

View file

@ -827,11 +827,6 @@ pub enum ValueDef<'a> {
preceding_comment: Region,
},
ExpectFx {
condition: &'a Loc<Expr<'a>>,
preceding_comment: Region,
},
/// e.g. `import InternalHttp as Http exposing [Req]`.
ModuleImport(ModuleImport<'a>),
@ -1070,10 +1065,6 @@ impl<'a, 'b> Iterator for RecursiveValueDefIter<'a, 'b> {
| ValueDef::Expect {
condition,
preceding_comment: _,
}
| ValueDef::ExpectFx {
condition,
preceding_comment: _,
} => self.push_pending_from_expr(&condition.value),
ValueDef::ModuleImport(ModuleImport {
@ -2726,10 +2717,6 @@ impl<'a> Malformed for ValueDef<'a> {
| ValueDef::Expect {
condition,
preceding_comment: _,
}
| ValueDef::ExpectFx {
condition,
preceding_comment: _,
} => condition.is_malformed(),
ValueDef::ModuleImport(ModuleImport {
before_name: _,

View file

@ -2619,11 +2619,9 @@ fn expect_help<'a>(
preceding_comment: Region,
) -> impl Parser<'a, Stmt<'a>, EExpect<'a>> {
move |arena: &'a Bump, state: State<'a>, min_indent| {
let parse_expect_vanilla = crate::parser::keyword(crate::keyword::EXPECT, EExpect::Expect);
let parse_expect_fx = crate::parser::keyword(crate::keyword::EXPECT_FX, EExpect::Expect);
let parse_expect = either(parse_expect_vanilla, parse_expect_fx);
let parse_expect = crate::parser::keyword(crate::keyword::EXPECT, EExpect::Expect);
let (_, kw, state) = parse_expect.parse(arena, state, min_indent)?;
let (_, _kw, state) = parse_expect.parse(arena, state, min_indent)?;
let (_, condition, state) = parse_block(
options,
@ -2635,15 +2633,9 @@ fn expect_help<'a>(
)
.map_err(|(_, f)| (MadeProgress, f))?;
let vd = match kw {
Either::First(_) => ValueDef::Expect {
condition: arena.alloc(condition),
preceding_comment,
},
Either::Second(_) => ValueDef::ExpectFx {
condition: arena.alloc(condition),
preceding_comment,
},
let vd = ValueDef::Expect {
condition: arena.alloc(condition),
preceding_comment,
};
Ok((MadeProgress, Stmt::ValueDef(vd), state))

View file

@ -8,7 +8,6 @@ pub const IS: &str = "is";
pub const DBG: &str = "dbg";
pub const IMPORT: &str = "import";
pub const EXPECT: &str = "expect";
pub const EXPECT_FX: &str = "expect-fx";
pub const RETURN: &str = "return";
pub const CRASH: &str = "crash";
@ -22,6 +21,6 @@ pub const WHERE: &str = "where";
// These keywords are valid in headers
pub const PLATFORM: &str = "platform";
pub const KEYWORDS: [&str; 12] = [
IF, THEN, ELSE, WHEN, AS, IS, DBG, IMPORT, EXPECT, EXPECT_FX, RETURN, CRASH,
pub const KEYWORDS: [&str; 11] = [
IF, THEN, ELSE, WHEN, AS, IS, DBG, IMPORT, EXPECT, RETURN, CRASH,
];

View file

@ -427,13 +427,6 @@ impl<'a> Normalize<'a> for ValueDef<'a> {
condition: arena.alloc(condition.normalize(arena)),
preceding_comment: Region::zero(),
},
ExpectFx {
condition,
preceding_comment: _,
} => ExpectFx {
condition: arena.alloc(condition.normalize(arena)),
preceding_comment: Region::zero(),
},
ModuleImport(module_import) => ModuleImport(module_import.normalize(arena)),
IngestedFileImport(ingested_file_import) => {
IngestedFileImport(ingested_file_import.normalize(arena))

View file

@ -1,39 +0,0 @@
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@25-41,
],
space_before: [
Slice { start: 0, length: 1 },
],
space_after: [
Slice { start: 1, length: 1 },
],
spaces: [
LineComment(
" expecting some effects",
),
Newline,
],
type_defs: [],
value_defs: [
ExpectFx {
condition: @35-41 BinOps(
[
(
@35-36 Num(
"5",
),
@37-39 Equals,
),
],
@40-41 Num(
"2",
),
),
preceding_comment: @0-24,
},
],
}

View file

@ -1,2 +0,0 @@
# expecting some effects
expect-fx 5 == 2

View file

@ -333,7 +333,6 @@ mod test_snapshots {
pass/equals_with_spaces.expr,
pass/expect.expr,
pass/expect_defs.moduledefs,
pass/expect_fx.moduledefs,
pass/expect_single_line.expr,
pass/extra_newline.expr,
pass/extra_newline_in_parens.expr,