diff --git a/src/library/user_recursors.cpp b/src/library/user_recursors.cpp index ceff1361f..d1879689b 100644 --- a/src/library/user_recursors.cpp +++ b/src/library/user_recursors.cpp @@ -100,6 +100,10 @@ recursor_info mk_recursor_info(environment const & env, name const & r, optional dep_elim = true; else dep_elim = false; + } else if (C_args.empty()) { + throw exception(sstream() << "invalid user defined recursor, '" << r << "' does not support dependent elimination, " + << "and position of the major premise was not specified " + << "(solution: set attribute '[recursor ]', where is the position of the major premise)"); } else { major = C_args.back(); dep_elim = true; diff --git a/tests/lean/user_rec_crash.lean b/tests/lean/user_rec_crash.lean new file mode 100644 index 000000000..80c3f8490 --- /dev/null +++ b/tests/lean/user_rec_crash.lean @@ -0,0 +1,4 @@ +example (a b : Prop) (h : a ∧ b) : a := +begin + induction h using and.rec_on with h₁ h₂, +end diff --git a/tests/lean/user_rec_crash.lean.expected.out b/tests/lean/user_rec_crash.lean.expected.out new file mode 100644 index 000000000..83ea15216 --- /dev/null +++ b/tests/lean/user_rec_crash.lean.expected.out @@ -0,0 +1,14 @@ +induction: h and.rec_on (h₁ h₂) +user_rec_crash.lean:3:2: error:invalid 'induction' tactic, invalid user defined recursor, 'and.rec_on' does not support dependent elimination, and position of the major premise was not specified (solution: set attribute '[recursor ]', where is the position of the major premise) +proof state: +a b : Prop, +h : a ∧ b +⊢ a +user_rec_crash.lean:4:0: error: don't know how to synthesize placeholder +a b : Prop, +h : a ∧ b +⊢ a +user_rec_crash.lean:4:0: error: failed to add declaration '14.0' to environment, value has metavariables +remark: set 'formatter.hide_full_terms' to false to see the complete term + λ (a b : Prop) (h : …), + ?M_1