feat(frontends/lean/parser): protect imported modules from Lua definitions and macros in the file importing the module
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
ba02132a90
commit
8e4560a866
5 changed files with 23 additions and 1 deletions
|
@ -2346,7 +2346,8 @@ class parser::imp {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
parser import_parser(m_env, m_io_state, in, m_script_state, true /* use exceptions */, false /* not interactive */);
|
||||
script_state state; // Empty state object for the imported module
|
||||
parser import_parser(m_env, m_io_state, in, &state, true /* use exceptions */, false /* not interactive */);
|
||||
import_parser();
|
||||
} catch (interrupted &) {
|
||||
throw;
|
||||
|
|
11
tests/lean/macro.lean
Normal file
11
tests/lean/macro.lean
Normal file
|
@ -0,0 +1,11 @@
|
|||
(**
|
||||
macro("IdMacro",
|
||||
{ macro_arg.Expr },
|
||||
function (env, e)
|
||||
return e
|
||||
end
|
||||
)
|
||||
**)
|
||||
|
||||
Show IdMacro 10.
|
||||
Import "module.lean"
|
5
tests/lean/macro.lean.expected.out
Normal file
5
tests/lean/macro.lean.expected.out
Normal file
|
@ -0,0 +1,5 @@
|
|||
Set: pp::colors
|
||||
Set: pp::unicode
|
||||
10
|
||||
Error (line: 2, pos: 5) unknown identifier 'IdMacro'
|
||||
Error (line: 11, pos: 0) failed to import file './module.lean'
|
2
tests/lean/module.lean
Normal file
2
tests/lean/module.lean
Normal file
|
@ -0,0 +1,2 @@
|
|||
(* The following command should fail because the IdMacro is not defined *)
|
||||
Show IdMacro 20.
|
3
tests/lean/module.lean.expected.out
Normal file
3
tests/lean/module.lean.expected.out
Normal file
|
@ -0,0 +1,3 @@
|
|||
Set: pp::colors
|
||||
Set: pp::unicode
|
||||
Error (line: 2, pos: 5) unknown identifier 'IdMacro'
|
Loading…
Reference in a new issue