lean4-htt/src/library/inductive_compiler
Leonardo de Moura 13c532d0d4 fix(*): truncation bugs
- Lean strings (like std::string) may contain null characters. The
  codebase was ignoring this issue.

- We now have a wrapper `string_ref` for wrapping Lean string objects in
  C++. This wrapper also implements correctly the coercions std::string <-> string_ref.
  Remark: I also found a few places where the code relies on the
  following property which is not true
  Forall s : std::string, std::string(s.c_str()) == s

- `name` object wrapper was assuming that all numerals were small
  `nat` values. This is true in most cases, but the system would
  crash when processing if it is a big number.

- The commit tries to make sure runtime/util/kernel are correct.
  Modules that will be deleted contain many `TODO` comments
  indicating they may crash and/or produce incorrect results
  when strings contain null characters and numerals are big.

cc @kha

@kha: I thought about using `string` instead of `string_ref`.
We consistently use `std::string`. So, it should be fine, but I
was concerned about code readability.

After we bootstrap Lean4, we will be able to delete `lean::list`
template, and rename `lean::list_ref` to `lean::list`.

I am going to add `pair_ref` for wrapping Lean pair objects.
If we use `lean::string` instead of `lean::string_ref`, then
we should also use `lean::pair` instead of `lean::pair_ref`.
But, there is a problem in this case since we have
https://github.com/leanprover/lean4/blob/master/src/util/pair.h#L13
:(
2018-06-15 16:05:11 -07:00
..
add_decl.cpp refactor(kernel): use m_meta instead of m_trusted 2018-05-31 11:18:00 -07:00
add_decl.h refactor(kernel): use m_meta instead of m_trusted 2018-05-31 11:18:00 -07:00
basic.cpp feat(kernel/inductive/inductive): dependent elimination for inductive predicates 2018-06-12 13:03:26 -07:00
basic.h refactor(kernel): use m_meta instead of m_trusted 2018-05-31 11:18:00 -07:00
CMakeLists.txt feat(src/library/inductive_compiler): support for nested inductive types 2016-09-16 12:50:59 -07:00
compiler.cpp refactor(kernel): use m_meta instead of m_trusted 2018-05-31 11:18:00 -07:00
compiler.h refactor(kernel): use m_meta instead of m_trusted 2018-05-31 11:18:00 -07:00
ginductive.cpp refactor(*): list<name> ==> obj_list<name> 2018-05-23 15:48:43 -07:00
ginductive.h refactor(*): list<name> ==> obj_list<name> 2018-05-23 15:48:43 -07:00
ginductive_decl.cpp fix(library/util): get_datatype_level should not assume inductive datatype result type is a sort 2017-03-02 11:42:16 -08:00
ginductive_decl.h refactor(*): list<name> ==> obj_list<name> 2018-05-23 15:48:43 -07:00
init_module.cpp refactor(library/inductive_compiler): do not use fresh names in the inductive compiler 2018-02-21 15:04:19 -08:00
init_module.h
mutual.cpp refactor(library/inductive_compiler): remove sizeof lemma generation 2018-06-12 13:03:25 -07:00
mutual.h refactor(kernel): use m_meta instead of m_trusted 2018-05-31 11:18:00 -07:00
nested.cpp fix(*): truncation bugs 2018-06-15 16:05:11 -07:00
nested.h refactor(kernel): use m_meta instead of m_trusted 2018-05-31 11:18:00 -07:00
util.cpp chore(library/inductive_compiler/util): fix assertion 2018-06-07 16:28:54 -07:00
util.h chore(*): type_context ==> type_context_old 2018-03-05 12:38:24 -08:00