feat(frontends/lean/decl_cmds): sign an error if "noncomputable" keyword is used in the HoTT library or with non-definitions

This commit is contained in:
Leonardo de Moura 2015-07-29 08:14:39 -07:00
parent 8a9f774611
commit 74be3031b1
5 changed files with 8 additions and 0 deletions

View file

@ -1070,6 +1070,10 @@ public:
m_is_private(is_private), m_is_protected(is_protected), m_is_noncomputable(is_noncomputable),
m_pos(p.pos()), m_attributes(kind == Abbreviation || kind == LocalAbbreviation) {
lean_assert(!(m_is_private && m_is_protected));
if (!is_standard(m_p.env()) && is_noncomputable)
throw exception("invalid 'noncomputable' declarations, it can only be used in the standard library");
if (kind != Definition && is_noncomputable)
throw exception("invalid 'noncomputable' declaration, it can only be used for definitions");
}
environment operator()() {

View file

@ -0,0 +1 @@
noncomputable definition foo := 10

View file

@ -0,0 +1 @@
noncomp_hott.hlean:1:0: error: invalid 'noncomputable' declarations, it can only be used in the standard library

View file

@ -0,0 +1 @@
noncomputable theorem foo : true := trivial

View file

@ -0,0 +1 @@
noncomp_thm.lean:1:0: error: invalid 'noncomputable' declaration, it can only be used for definitions