Merge pull request #4174 from jopemachine/fix-dis

Always insert `None` at `code_stack.constants`
This commit is contained in:
Jeong YunWon 2022-10-01 22:45:08 +09:00 committed by GitHub
commit 438c73732e

View file

@ -1107,6 +1107,10 @@ impl Compiler {
let (doc_str, body) = split_doc(body);
self.current_codeinfo()
.constants
.insert_full(ConstantData::None);
self.compile_statements(body)?;
// Emit None at end:
@ -2122,6 +2126,11 @@ impl Compiler {
let name = "<lambda>".to_owned();
let mut funcflags = self.enter_function(&name, args)?;
self.current_codeinfo()
.constants
.insert_full(ConstantData::None);
self.compile_expression(body)?;
self.emit(Instruction::ReturnValue);
let code = self.pop_code_object();