Fix assert_known
This commit is contained in:
parent
8bbee5eb41
commit
2f56f148cb
@ -762,22 +762,26 @@ impl TypeKind {
|
|||||||
refs: &TypeRefs,
|
refs: &TypeRefs,
|
||||||
state: &TypecheckPassState,
|
state: &TypecheckPassState,
|
||||||
) -> Result<TypeKind, ErrorKind> {
|
) -> Result<TypeKind, ErrorKind> {
|
||||||
|
self.is_known(refs, state).map(|_| self.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_known(&self, refs: &TypeRefs, state: &TypecheckPassState) -> Result<(), ErrorKind> {
|
||||||
match &self {
|
match &self {
|
||||||
TypeKind::Array(type_kind, _) => type_kind.as_ref().assert_known(refs, state),
|
TypeKind::Array(type_kind, _) => type_kind.as_ref().is_known(refs, state),
|
||||||
TypeKind::CustomType(custom_type_key) => state
|
TypeKind::CustomType(custom_type_key) => state
|
||||||
.scope
|
.scope
|
||||||
.types
|
.types
|
||||||
.get(custom_type_key)
|
.get(custom_type_key)
|
||||||
.map(|_| self.clone())
|
.map(|_| ())
|
||||||
.ok_or(ErrorKind::NoSuchType(
|
.ok_or(ErrorKind::NoSuchType(
|
||||||
custom_type_key.0.clone(),
|
custom_type_key.0.clone(),
|
||||||
state.module_id.unwrap(),
|
state.module_id.unwrap(),
|
||||||
)),
|
)),
|
||||||
TypeKind::Borrow(type_kind, _) => type_kind.assert_known(refs, state),
|
TypeKind::Borrow(type_kind, _) => type_kind.is_known(refs, state),
|
||||||
TypeKind::UserPtr(type_kind) => type_kind.assert_known(refs, state),
|
TypeKind::UserPtr(type_kind) => type_kind.is_known(refs, state),
|
||||||
TypeKind::CodegenPtr(type_kind) => type_kind.assert_known(refs, state),
|
TypeKind::CodegenPtr(type_kind) => type_kind.is_known(refs, state),
|
||||||
TypeKind::Vague(vague_type) => Err(ErrorKind::TypeIsVague(*vague_type)),
|
TypeKind::Vague(vague_type) => Err(ErrorKind::TypeIsVague(*vague_type)),
|
||||||
_ => Ok(self.clone()),
|
_ => Ok(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
struct SDL_Thing {}
|
fn vec_sub(l: [f32; 3], r: [f32; 3]) -> [f32; 3] {
|
||||||
|
return [l[0]-r[0], l[1]-r[1], l[2]-r[2]];
|
||||||
extern fn SDL_malloc(size: u64) -> *SDL_Thing;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let pixels = SDL_malloc(4 * 320 * 240);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn foo(x: f32) {
|
||||||
|
let a = [x, x, 0.0];
|
||||||
|
let b = [x, x, x]; // works
|
||||||
|
// let b = [x * 0.5, x * 0.5, x]; // does not work
|
||||||
|
vec_sub(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Reference in New Issue
Block a user