mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
fixed typos, added typos checking to CI
This commit is contained in:
parent
960a4fddc5
commit
314503cf7f
43 changed files with 114 additions and 101 deletions
|
@ -40,7 +40,7 @@ pub fn infer_borrow<'a>(
|
|||
|
||||
// This is a fixed-point analysis
|
||||
//
|
||||
// all functions initiall own all their paramters
|
||||
// all functions initiall own all their parameters
|
||||
// through a series of checks and heuristics, some arguments are set to borrowed
|
||||
// when that doesn't lead to conflicts the change is kept, otherwise it may be reverted
|
||||
//
|
||||
|
@ -348,7 +348,7 @@ impl<'a> BorrowInfState<'a> {
|
|||
/// let z = e in ...
|
||||
///
|
||||
/// and determines whether z and which of the symbols used in e
|
||||
/// must be taken as owned paramters
|
||||
/// must be taken as owned parameters
|
||||
fn collect_call(&mut self, z: Symbol, e: &crate::ir::Call<'a>) {
|
||||
use crate::ir::CallType::*;
|
||||
|
||||
|
|
|
@ -7,16 +7,16 @@ use roc_collections::all::{MutMap, MutSet};
|
|||
use roc_module::symbol::Symbol;
|
||||
|
||||
pub fn free_variables(stmt: &Stmt<'_>) -> MutSet<Symbol> {
|
||||
let (mut occuring, bound) = occuring_variables(stmt);
|
||||
let (mut occurring, bound) = occurring_variables(stmt);
|
||||
|
||||
for ref s in bound {
|
||||
occuring.remove(s);
|
||||
occurring.remove(s);
|
||||
}
|
||||
|
||||
occuring
|
||||
occurring
|
||||
}
|
||||
|
||||
pub fn occuring_variables(stmt: &Stmt<'_>) -> (MutSet<Symbol>, MutSet<Symbol>) {
|
||||
pub fn occurring_variables(stmt: &Stmt<'_>) -> (MutSet<Symbol>, MutSet<Symbol>) {
|
||||
let mut stack = std::vec![stmt];
|
||||
let mut result = MutSet::default();
|
||||
let mut bound_variables = MutSet::default();
|
||||
|
@ -26,7 +26,7 @@ pub fn occuring_variables(stmt: &Stmt<'_>) -> (MutSet<Symbol>, MutSet<Symbol>) {
|
|||
|
||||
match stmt {
|
||||
Let(symbol, expr, _, cont) => {
|
||||
occuring_variables_expr(expr, &mut result);
|
||||
occurring_variables_expr(expr, &mut result);
|
||||
result.insert(*symbol);
|
||||
bound_variables.insert(*symbol);
|
||||
stack.push(cont);
|
||||
|
@ -39,7 +39,7 @@ pub fn occuring_variables(stmt: &Stmt<'_>) -> (MutSet<Symbol>, MutSet<Symbol>) {
|
|||
fail,
|
||||
..
|
||||
} => {
|
||||
occuring_variables_call(call, &mut result);
|
||||
occurring_variables_call(call, &mut result);
|
||||
result.insert(*symbol);
|
||||
bound_variables.insert(*symbol);
|
||||
stack.push(pass);
|
||||
|
@ -93,13 +93,13 @@ pub fn occuring_variables(stmt: &Stmt<'_>) -> (MutSet<Symbol>, MutSet<Symbol>) {
|
|||
(result, bound_variables)
|
||||
}
|
||||
|
||||
fn occuring_variables_call(call: &crate::ir::Call<'_>, result: &mut MutSet<Symbol>) {
|
||||
fn occurring_variables_call(call: &crate::ir::Call<'_>, result: &mut MutSet<Symbol>) {
|
||||
// NOTE though the function name does occur, it is a static constant in the program
|
||||
// for liveness, it should not be included here.
|
||||
result.extend(call.arguments.iter().copied());
|
||||
}
|
||||
|
||||
pub fn occuring_variables_expr(expr: &Expr<'_>, result: &mut MutSet<Symbol>) {
|
||||
pub fn occurring_variables_expr(expr: &Expr<'_>, result: &mut MutSet<Symbol>) {
|
||||
use Expr::*;
|
||||
|
||||
match expr {
|
||||
|
@ -109,7 +109,7 @@ pub fn occuring_variables_expr(expr: &Expr<'_>, result: &mut MutSet<Symbol>) {
|
|||
result.insert(*symbol);
|
||||
}
|
||||
|
||||
Call(call) => occuring_variables_call(call, result),
|
||||
Call(call) => occurring_variables_call(call, result),
|
||||
|
||||
Tag { arguments, .. }
|
||||
| Struct(arguments)
|
||||
|
@ -160,13 +160,13 @@ struct Context<'a> {
|
|||
fn update_live_vars<'a>(expr: &Expr<'a>, v: &LiveVarSet) -> LiveVarSet {
|
||||
let mut v = v.clone();
|
||||
|
||||
occuring_variables_expr(expr, &mut v);
|
||||
occurring_variables_expr(expr, &mut v);
|
||||
|
||||
v
|
||||
}
|
||||
|
||||
/// `isFirstOcc xs x i = true` if `xs[i]` is the first occurrence of `xs[i]` in `xs`
|
||||
fn is_first_occurence(xs: &[Symbol], i: usize) -> bool {
|
||||
fn is_first_occurrence(xs: &[Symbol], i: usize) -> bool {
|
||||
match xs.get(i) {
|
||||
None => unreachable!(),
|
||||
Some(s) => i == xs.iter().position(|v| s == v).unwrap(),
|
||||
|
@ -319,7 +319,7 @@ impl<'a> Context<'a> {
|
|||
{
|
||||
for (i, x) in xs.iter().enumerate() {
|
||||
let info = self.get_var_info(*x);
|
||||
if !info.reference || !is_first_occurence(xs, i) {
|
||||
if !info.reference || !is_first_occurrence(xs, i) {
|
||||
// do nothing
|
||||
} else {
|
||||
let num_consumptions = get_num_consumptions(*x, xs, consume_param_pred.clone()); // number of times the argument is used
|
||||
|
@ -393,7 +393,7 @@ impl<'a> Context<'a> {
|
|||
// Remark: `x` may occur multiple times in the application (e.g., `f x y x`).
|
||||
// This is why we check whether it is the first occurrence.
|
||||
if self.must_consume(*x)
|
||||
&& is_first_occurence(xs, i)
|
||||
&& is_first_occurrence(xs, i)
|
||||
&& is_borrow_param(*x, xs, ps)
|
||||
&& !b_live_vars.contains(x)
|
||||
{
|
||||
|
@ -418,7 +418,7 @@ impl<'a> Context<'a> {
|
|||
This is why we check whether it is the first occurrence. */
|
||||
|
||||
if self.must_consume(*x)
|
||||
&& is_first_occurence(xs, i)
|
||||
&& is_first_occurrence(xs, i)
|
||||
&& *is_borrow
|
||||
&& !b_live_vars.contains(x)
|
||||
{
|
||||
|
@ -1096,7 +1096,7 @@ pub fn collect_stmt(
|
|||
vars = collect_stmt(cont, jp_live_vars, vars);
|
||||
vars.remove(symbol);
|
||||
let mut result = MutSet::default();
|
||||
occuring_variables_expr(expr, &mut result);
|
||||
occurring_variables_expr(expr, &mut result);
|
||||
vars.extend(result);
|
||||
|
||||
vars
|
||||
|
@ -1114,7 +1114,7 @@ pub fn collect_stmt(
|
|||
vars.remove(symbol);
|
||||
|
||||
let mut result = MutSet::default();
|
||||
occuring_variables_call(call, &mut result);
|
||||
occurring_variables_call(call, &mut result);
|
||||
|
||||
vars.extend(result);
|
||||
|
||||
|
|
|
@ -7663,7 +7663,7 @@ pub fn num_argument_to_int_or_float(
|
|||
4 => IntOrFloat::UnsignedIntType(IntPrecision::I32),
|
||||
8 => IntOrFloat::UnsignedIntType(IntPrecision::I64),
|
||||
_ => panic!(
|
||||
"Invalid target for Num type arguement: Roc does't support compiling to {}-bit systems.",
|
||||
"Invalid target for Num type argument: Roc does't support compiling to {}-bit systems.",
|
||||
ptr_bytes * 8
|
||||
),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue