diff --git a/src/library/compiler/specialize.cpp b/src/library/compiler/specialize.cpp index 267230e6d3..4b6d90475a 100644 --- a/src/library/compiler/specialize.cpp +++ b/src/library/compiler/specialize.cpp @@ -433,9 +433,11 @@ class specialize_fn { } } - void get_bool_mask(name const & fn, buffer & mask) { + void get_bool_mask(name const & fn, unsigned args_size, buffer & mask) { buffer kinds; get_arg_kinds(fn, kinds); + if (kinds.size() > args_size) + kinds.shrink(args_size); to_bool_mask(kinds, has_specialize_attribute(env(), fn), mask); } @@ -541,7 +543,7 @@ class specialize_fn { get_arg_kinds(const_name(fn), kinds); bool has_attr = has_specialize_attribute(env(), const_name(fn)); name_set collected; - unsigned sz = kinds.size(); + unsigned sz = std::min(kinds.size(), args.size()); unsigned i = sz; bool found_inst = false; while (i > 0) { @@ -600,7 +602,7 @@ class specialize_fn { buffer args; get_app_args(e, args); buffer bmask; - get_bool_mask(const_name(fn), bmask); + get_bool_mask(const_name(fn), args.size(), bmask); lean_assert(bmask.size() <= args.size()); buffer> new_mask; bool found = false; @@ -851,7 +853,7 @@ class specialize_fn { return none_expr(); specialize_init_deps(fn, args, ctx); buffer bmask; - get_bool_mask(const_name(fn), bmask); + get_bool_mask(const_name(fn), args.size(), bmask); buffer> mask; buffer fvars; buffer fvar_vals;