fix(frontends/lean/parser): fixes #616

This commit is contained in:
Leonardo de Moura 2015-05-20 23:33:41 -07:00
parent d6b72ef4d7
commit 89581cead7
6 changed files with 40 additions and 0 deletions

View file

@ -1679,6 +1679,7 @@ void parser::parse_imports() {
bool prelude = false;
std::string base = dirname(get_stream_name().c_str());
bool imported = false;
unsigned fingerprint = 0;
if (curr_is_token(get_prelude_tk())) {
next();
prelude = true;
@ -1716,6 +1717,9 @@ void parser::parse_imports() {
if (!curr_is_identifier())
break;
name f = get_name_val();
fingerprint = hash(fingerprint, f.hash());
if (k)
fingerprint = hash(fingerprint, *k);
if (auto it = try_file(f, ".lua")) {
if (k)
throw parser_error(sstream() << "invalid import, failed to import '" << f
@ -1733,6 +1737,7 @@ void parser::parse_imports() {
bool keep_imported_thms = (m_keep_theorem_mode == keep_theorem_mode::All);
m_env = import_modules(m_env, base, olean_files.size(), olean_files.data(), num_threads,
keep_imported_thms, m_ios);
m_env = update_fingerprint(m_env, fingerprint);
for (auto const & f : lua_files) {
std::string rname = find_file(f, {".lua"});
system_import(rname.c_str());

View file

@ -46,6 +46,9 @@ add_test(NAME "auto_completion_issue_422"
add_test(NAME "issue_597"
WORKING_DIRECTORY "${LEAN_SOURCE_DIR}/../tests/lean/extra"
COMMAND bash "./issue_597.sh" "${CMAKE_CURRENT_BINARY_DIR}/lean")
add_test(NAME "issue_616"
WORKING_DIRECTORY "${LEAN_SOURCE_DIR}/../tests/lean/extra"
COMMAND bash "./issue_616.sh" "${CMAKE_CURRENT_BINARY_DIR}/lean")
# LEAN TESTS
file(GLOB LEANTESTS "${LEAN_SOURCE_DIR}/../tests/lean/*.lean")

View file

@ -0,0 +1 @@
attribute type_quotient.rec [recursor]

View file

@ -0,0 +1,9 @@
import .f616a
open eq
definition my_elim {A P : Type} {R : A → A → Type} (Pc : A → P)
(Pp : Π⦃a a' : A⦄ (H : R a a'), Pc a = Pc a') (x : type_quotient R) : P :=
begin
induction x,
exact (Pc a),
refine (!tr_constant ⬝ Pp H)
end

View file

@ -0,0 +1,8 @@
open eq
definition my_elim {A P : Type} {R : A → A → Type} (Pc : A → P)
(Pp : Π⦃a a' : A⦄ (H : R a a'), Pc a = Pc a') (x : type_quotient R) : P :=
begin
induction x,
exact (Pc a),
refine (!tr_constant ⬝ Pp H)
end

14
tests/lean/extra/issue_616.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
set -e
if [ $# -ne 1 ]; then
echo "Usage: issue_616.sh [lean-executable-path]"
exit 1
fi
LEAN=$1
export HLEAN_PATH=../../../hott
"$LEAN" -o f616a.olean 616a.hlean
"$LEAN" -c 616.clean 616b.hlean
if "$LEAN" -c 616.clean 616c.hlean; then
echo "ERROR: using incorrect cached value..."
exit 1
fi