d87ad9eb7e
The following call sequence is possible: C++ -> Lua -> C++ -> Lua -> C++ The first block of C++ is the Lean main function. The main function invokes the Lua interpreter. The Lua interpreter invokes a C++ Lean API. Then the Lean API invokes a callback implemented in Lua. The Lua callback invokes another Lean API. Now, suppose the Lean API throws an exception. We want the C++ exception to propagate over the mixed C++/Lua call stack. We use the clone/rethrow exception idiom to achieve this goal. Before this commit, the C++ exceptions were converted into strings using the method what(), and then they were propagated over the Lua stack using lua_error. A lua_error was then converted into a lua_exception when going back to C++. This solution was very unsatisfactory, since all C++ exceptions were being converted into a lua_exception, and consequently the structure of the exception was being lost. Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
162 lines
7.4 KiB
Text
162 lines
7.4 KiB
Text
Set: pp::colors
|
||
Set: pp::unicode
|
||
Assumed: i
|
||
Assumed: j
|
||
Assumed: p
|
||
elaborator exception
|
||
Failed to solve
|
||
⊢ (?M::0 ≈ Nat::add) ⊕ (?M::0 ≈ Int::add) ⊕ (?M::0 ≈ Real::add)
|
||
Overloading at
|
||
(Real::add | Int::add | Nat::add) i p
|
||
Failed to solve
|
||
⊢ (?M::1 ≈ λ x : ℤ, x) ⊕ (?M::1 ≈ int_to_real)
|
||
Coercion for
|
||
i
|
||
Failed to solve
|
||
⊢ ℤ ≺ ℕ
|
||
Substitution
|
||
⊢ ℤ ≺ ?M::6
|
||
Substitution
|
||
⊢ (?M::5[inst:0 i]) i ≺ ?M::6
|
||
Type of argument 1 must be convertible to the expected type in the application of
|
||
?M::0
|
||
with arguments:
|
||
?M::1 i
|
||
p
|
||
Assignment
|
||
x : ℤ ⊢ λ x : ℤ, ℤ ≈ ?M::5
|
||
Destruct/Decompose
|
||
x : ℤ ⊢ ℤ ≈ ?M::5 x
|
||
Destruct/Decompose
|
||
⊢ ℤ → ℤ ≈ Π x : ?M::4, ?M::5 x
|
||
Substitution
|
||
⊢ ?M::3 ≈ Π x : ?M::4, ?M::5 x
|
||
Function expected at
|
||
?M::1 i
|
||
Assignment
|
||
⊢ ℤ → ℤ ≺ ?M::3
|
||
Propagate type, ?M::1 : ?M::3
|
||
Assignment
|
||
⊢ ?M::1 ≈ λ x : ℤ, x
|
||
Assumption 1
|
||
Assignment
|
||
⊢ ℕ ≈ ?M::6
|
||
Destruct/Decompose
|
||
⊢ ℕ → ℕ → ℕ ≈ Π x : ?M::6, ?M::7 x
|
||
Substitution
|
||
⊢ ?M::2 ≈ Π x : ?M::6, ?M::7 x
|
||
Function expected at
|
||
?M::0 (?M::1 i) p
|
||
Assignment
|
||
⊢ ℕ → ℕ → ℕ ≺ ?M::2
|
||
Propagate type, ?M::0 : ?M::2
|
||
Assignment
|
||
⊢ ?M::0 ≈ Nat::add
|
||
Assumption 0
|
||
Failed to solve
|
||
⊢ ℝ ≺ ℕ
|
||
Substitution
|
||
⊢ ℝ ≺ ?M::6
|
||
Substitution
|
||
⊢ (?M::5[inst:0 i]) i ≺ ?M::6
|
||
Type of argument 1 must be convertible to the expected type in the application of
|
||
?M::0
|
||
with arguments:
|
||
?M::1 i
|
||
p
|
||
Assignment
|
||
_ : ℤ ⊢ λ x : ℤ, ℝ ≈ ?M::5
|
||
Destruct/Decompose
|
||
_ : ℤ ⊢ ℝ ≈ ?M::5 _
|
||
Destruct/Decompose
|
||
⊢ ℤ → ℝ ≈ Π x : ?M::4, ?M::5 x
|
||
Substitution
|
||
⊢ ?M::3 ≈ Π x : ?M::4, ?M::5 x
|
||
Function expected at
|
||
?M::1 i
|
||
Assignment
|
||
⊢ ℤ → ℝ ≺ ?M::3
|
||
Propagate type, ?M::1 : ?M::3
|
||
Assignment
|
||
⊢ ?M::1 ≈ int_to_real
|
||
Assumption 2
|
||
Assignment
|
||
⊢ ℕ ≈ ?M::6
|
||
Destruct/Decompose
|
||
⊢ ℕ → ℕ → ℕ ≈ Π x : ?M::6, ?M::7 x
|
||
Substitution
|
||
⊢ ?M::2 ≈ Π x : ?M::6, ?M::7 x
|
||
Function expected at
|
||
?M::0 (?M::1 i) p
|
||
Assignment
|
||
⊢ ℕ → ℕ → ℕ ≺ ?M::2
|
||
Propagate type, ?M::0 : ?M::2
|
||
Assignment
|
||
⊢ ?M::0 ≈ Nat::add
|
||
Assumption 0
|
||
Failed to solve
|
||
⊢ Bool ≺ ℤ
|
||
Substitution
|
||
⊢ Bool ≺ ?M::8
|
||
Type of argument 2 must be convertible to the expected type in the application of
|
||
?M::0
|
||
with arguments:
|
||
?M::1 i
|
||
p
|
||
Assignment
|
||
⊢ ℤ ≈ ?M::8
|
||
Destruct/Decompose
|
||
⊢ ℤ → ℤ ≈ Π x : ?M::8, ?M::9 x
|
||
Substitution
|
||
⊢ (?M::7[inst:0 (?M::1 i)]) (?M::1 i) ≈ Π x : ?M::8, ?M::9 x
|
||
Function expected at
|
||
?M::0 (?M::1 i) p
|
||
Assignment
|
||
_ : ℤ ⊢ λ x : ℤ, ℤ → ℤ ≈ ?M::7
|
||
Destruct/Decompose
|
||
_ : ℤ ⊢ ℤ → ℤ ≈ ?M::7 _
|
||
Destruct/Decompose
|
||
⊢ ℤ → ℤ → ℤ ≈ Π x : ?M::6, ?M::7 x
|
||
Substitution
|
||
⊢ ?M::2 ≈ Π x : ?M::6, ?M::7 x
|
||
Function expected at
|
||
?M::0 (?M::1 i) p
|
||
Assignment
|
||
⊢ ℤ → ℤ → ℤ ≺ ?M::2
|
||
Propagate type, ?M::0 : ?M::2
|
||
Assignment
|
||
⊢ ?M::0 ≈ Int::add
|
||
Assumption 3
|
||
Failed to solve
|
||
⊢ Bool ≺ ℝ
|
||
Substitution
|
||
⊢ Bool ≺ ?M::8
|
||
Type of argument 2 must be convertible to the expected type in the application of
|
||
?M::0
|
||
with arguments:
|
||
?M::1 i
|
||
p
|
||
Assignment
|
||
⊢ ℝ ≈ ?M::8
|
||
Destruct/Decompose
|
||
⊢ ℝ → ℝ ≈ Π x : ?M::8, ?M::9 x
|
||
Substitution
|
||
⊢ (?M::7[inst:0 (?M::1 i)]) (?M::1 i) ≈ Π x : ?M::8, ?M::9 x
|
||
Function expected at
|
||
?M::0 (?M::1 i) p
|
||
Assignment
|
||
_ : ℝ ⊢ λ x : ℝ, ℝ → ℝ ≈ ?M::7
|
||
Destruct/Decompose
|
||
_ : ℝ ⊢ ℝ → ℝ ≈ ?M::7 _
|
||
Destruct/Decompose
|
||
⊢ ℝ → ℝ → ℝ ≈ Π x : ?M::6, ?M::7 x
|
||
Substitution
|
||
⊢ ?M::2 ≈ Π x : ?M::6, ?M::7 x
|
||
Function expected at
|
||
?M::0 (?M::1 i) p
|
||
Assignment
|
||
⊢ ℝ → ℝ → ℝ ≺ ?M::2
|
||
Propagate type, ?M::0 : ?M::2
|
||
Assignment
|
||
⊢ ?M::0 ≈ Real::add
|
||
Assumption 5
|