Skip to content

Commit

Permalink
fix(library/module): do not implicitly cast bool to int (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
gebner committed May 18, 2020
1 parent ba05c95 commit 2b7bc91
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/library/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct module_ext : public environment_extension {
/** Top-level doc strings for modules which have them. Lean doesn't have a notion
* of module different from that of a source file, so we use file names to index
* the docstring map. */
rb_map<std::string, list<std::pair<pos_info, std::string>>, string_lt> m_module_docs;
rb_map<std::string, list<std::pair<pos_info, std::string>>, string_cmp> m_module_docs;
// Map from declaration name to olean file where it was defined
name_map<std::string> m_decl2olean;
name_map<pos_info> m_decl2pos_info;
Expand Down Expand Up @@ -541,7 +541,7 @@ environment add_doc_string(environment const & env, std::string const & doc, pos
return add(env, std::make_shared<mod_doc_modification>(doc, pos));
}

rb_map<std::string, list<std::pair<pos_info, std::string>>, string_lt> const & get_doc_strings(environment const & env) {
rb_map<std::string, list<std::pair<pos_info, std::string>>, string_cmp> const & get_doc_strings(environment const & env) {
return get_extension(env).m_module_docs;
}

Expand Down
2 changes: 1 addition & 1 deletion src/library/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ environment add(environment const & env, certified_declaration const & d);
environment add_doc_string(environment const & env, std::string const & doc, pos_info pos);

/** \brief Returns the map of module-level docs indexed by source file name. */
rb_map<std::string, list<std::pair<pos_info, std::string>>, string_lt> const & get_doc_strings(environment const & env);
rb_map<std::string, list<std::pair<pos_info, std::string>>, string_cmp> const & get_doc_strings(environment const & env);

/** \brief Return true iff \c n is a definition added to the current module using #module::add */
bool is_definition(environment const & env, name const & n);
Expand Down
6 changes: 3 additions & 3 deletions src/library/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ std::string quote_string_literal(std::string const & s);
format pp_string_literal(std::string const & s);
format pp_char_literal(unsigned c);

struct string_lt {
bool operator()(std::string const & a, std::string const & b) const {
return a < b;
struct string_cmp {
int operator()(std::string const & a, std::string const & b) const {
return a.compare(b);
}
};

Expand Down
2 changes: 2 additions & 0 deletions tests/lean/run/doc_string7a.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/-!a-/
/-!b-/
11 changes: 11 additions & 0 deletions tests/lean/run/doc_string7b.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import .doc_string7a
open tactic

#eval do
ds ← olean_doc_strings,
let ds := (do
⟨some fn, d⟩ ← ds | [],
guard $ fn.backn 17 = "doc_string7a.lean",
d),
trace ds,
guard $ ds = [(⟨1, 0⟩, "a"), (⟨2,0⟩, "b")]

0 comments on commit 2b7bc91

Please sign in to comment.