mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Mono IR checker: check wanted function pointer layout
This commit is contained in:
parent
e1c88c6101
commit
13c45151a4
1 changed files with 25 additions and 6 deletions
|
@ -511,14 +511,33 @@ impl<'a, 'r> Ctx<'a, 'r> {
|
|||
}
|
||||
&Expr::FunctionPointer { lambda_name } => {
|
||||
let lambda_symbol = lambda_name.name();
|
||||
if !self.procs.iter().any(|((name, proc), _)| {
|
||||
let proc = self.procs.iter().find(|((name, proc), _)| {
|
||||
*name == lambda_symbol && proc.niche == lambda_name.niche()
|
||||
}) {
|
||||
self.problem(ProblemKind::PtrToUndefinedProc {
|
||||
symbol: lambda_symbol,
|
||||
});
|
||||
});
|
||||
match proc {
|
||||
None => {
|
||||
self.problem(ProblemKind::PtrToUndefinedProc {
|
||||
symbol: lambda_symbol,
|
||||
});
|
||||
Some(target_layout)
|
||||
}
|
||||
Some(((_, proc_layout), _)) => {
|
||||
let ProcLayout {
|
||||
arguments, result, ..
|
||||
} = proc_layout;
|
||||
|
||||
let fn_ptr =
|
||||
self.interner
|
||||
.insert_direct_no_semantic(LayoutRepr::FunctionPointer(
|
||||
FunctionPointer {
|
||||
args: arguments,
|
||||
ret: *result,
|
||||
},
|
||||
));
|
||||
|
||||
Some(fn_ptr)
|
||||
}
|
||||
}
|
||||
Some(target_layout)
|
||||
}
|
||||
&Expr::Reset {
|
||||
symbol,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue