Merge pull request #1580 from seeeturtle/doc-f

Set docstring of function as None if not declared
This commit is contained in:
Aviv Palivoda 2019-11-02 19:18:11 +02:00 committed by GitHub
commit 47c8f3756b

View file

@ -1015,14 +1015,16 @@ impl<O: OutputStream> Compiler<O> {
}
fn store_docstring(&mut self, doc_str: Option<String>) {
if let Some(doc_string) = doc_str {
// Duplicate top of stack (the function or class object)
self.emit(Instruction::Duplicate);
// Doc string value:
self.emit(Instruction::LoadConst {
value: bytecode::Constant::String {
value: doc_string.to_string(),
value: match doc_str {
Some(doc) => bytecode::Constant::String {
value: doc.to_string(),
},
None => bytecode::Constant::None, // set docstring None if not declared
},
});
@ -1031,7 +1033,6 @@ impl<O: OutputStream> Compiler<O> {
name: "__doc__".to_string(),
});
}
}
fn compile_while(
&mut self,