mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-01 21:40:58 +00:00
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:
parent
7bf3701c9e
commit
9ead801536
32 changed files with 21 additions and 641 deletions
|
|
@ -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"),
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue