Code gardening.
This commit is contained in:
parent
64435f1831
commit
7be2c3e525
2 changed files with 8 additions and 3 deletions
|
@ -76,7 +76,7 @@ impl Context {
|
|||
.any(|t| t.name() == Some(name.clone()) && !t.is_unresolved())
|
||||
{
|
||||
let message = format!("Type {} redefined", self.get_string(name).unwrap());
|
||||
self.compile_error(&message, location.clone(), ErrorKind::TypeRedefined)
|
||||
self.compile_error(&message, location.clone(), ErrorKind::TypeRedefined);
|
||||
}
|
||||
|
||||
let idx = self.types.len();
|
||||
|
@ -219,7 +219,7 @@ impl Context {
|
|||
// This can theoretically return another type reference, so we still
|
||||
// have to do a full type-check.
|
||||
for (i, ty) in self.types.iter().enumerate() {
|
||||
if ty.name().is_some() && &ty.name().unwrap() == name {
|
||||
if ty.name() == Some(name.clone()) {
|
||||
return i.into();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::block::BlockIdx;
|
||||
use crate::stable::StringIdx;
|
||||
use crate::ty::TyIdx;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Function {
|
||||
|
@ -29,12 +30,16 @@ impl Function {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct Clause {
|
||||
arguments: Vec<(StringIdx, TyIdx)>,
|
||||
arguments: BTreeMap<StringIdx, TyIdx>,
|
||||
body: BlockIdx,
|
||||
}
|
||||
|
||||
impl Clause {
|
||||
pub fn new(arguments: Vec<(StringIdx, TyIdx)>, body: BlockIdx) -> Clause {
|
||||
let arguments = arguments.iter().fold(BTreeMap::new(), |mut args, (k, v)| {
|
||||
args.insert(k.clone(), v.clone());
|
||||
args
|
||||
});
|
||||
Clause { arguments, body }
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue