Closed
Description
Ran into this while trying to generalize the "steal_exprs" part of my fuzzer.
fn safe_to_steal(e: &@ast::expr) -> bool {
alt e.node {
_ { true }
}
}
fn stash_if<T>(c: fn(&@T)->bool, es: @mutable [T], e: &@T) {
if c(e) {
*es += [*e];
}
}
fn steal_exprs(crate: &ast::crate) -> [ast::expr] {
let exprs: @mutable [ast::expr] = @mutable [];
let v = visit::mk_simple_visitor(@{
visit_expr: bind stash_if(safe_to_steal, exprs, _)
with *visit::default_simple_visitor()
});
visit::visit_crate(crate, (), v);;
*exprs
}
Here's a simpler testcase that also demonstrates the problem:
fn even(e: &int) -> bool {
e % 2 == 0
}
fn log_if<T>(c: fn(&T)->bool, e: &T) {
if c(e) { log e }
}
fn main() {
(bind log_if(even, _))(2);
}
Both the fuzzer piece and the simpler testcase result in:
Assertion failed: ((i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"), function init, file Instructions.cpp, line 274.
If I remove the ampersands from the simpler testcase, I get a different LLVM assertion:
Assertion failed: (S->getType()->isPointerTy() && "Invalid cast"), function CreatePointerCast, file Instructions.cpp, line 2334.
Metadata
Metadata
Assignees
Labels
No labels