Skip to content

Commit 9aaf887

Browse files
authored
Merge pull request RustPython#1367 from j30ng/syntax-err-on-star
Return SyntaxError on Invalid Star Expression
2 parents 0d15259 + a5bea47 commit 9aaf887

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

bytecode/src/bytecode.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ pub enum Instruction {
258258
before: usize,
259259
after: usize,
260260
},
261-
Unpack,
262261
FormatValue {
263262
conversion: Option<ConversionFlag>,
264263
spec: String,
@@ -522,7 +521,6 @@ impl Instruction {
522521
LoadBuildClass => w!(LoadBuildClass),
523522
UnpackSequence { size } => w!(UnpackSequence, size),
524523
UnpackEx { before, after } => w!(UnpackEx, before, after),
525-
Unpack => w!(Unpack),
526524
FormatValue { spec, .. } => w!(FormatValue, spec), // TODO: write conversion
527525
PopException => w!(PopException),
528526
Reverse { amount } => w!(Reverse, amount),

compiler/src/compile.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,10 +1616,13 @@ impl<O: OutputStream> Compiler<O> {
16161616
Comprehension { kind, generators } => {
16171617
self.compile_comprehension(kind, generators)?;
16181618
}
1619-
Starred { value } => {
1620-
self.compile_expression(value)?;
1621-
self.emit(Instruction::Unpack);
1622-
panic!("We should not just unpack a starred args, since the size is unknown.");
1619+
Starred { .. } => {
1620+
return Err(CompileError {
1621+
error: CompileErrorType::SyntaxError(std::string::String::from(
1622+
"Invalid starred expression",
1623+
)),
1624+
location: self.current_source_location.clone(),
1625+
});
16231626
}
16241627
IfExpression { test, body, orelse } => {
16251628
let no_label = self.new_label();

vm/src/frame.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ impl Frame {
478478
bytecode::Instruction::UnpackEx { before, after } => {
479479
self.execute_unpack_ex(vm, *before, *after)
480480
}
481-
bytecode::Instruction::Unpack => self.execute_unpack(vm),
482481
bytecode::Instruction::FormatValue { conversion, spec } => {
483482
use bytecode::ConversionFlag::*;
484483
let value = match conversion {
@@ -979,15 +978,6 @@ impl Frame {
979978
}
980979
}
981980

982-
fn execute_unpack(&self, vm: &VirtualMachine) -> FrameResult {
983-
let value = self.pop_value();
984-
let elements = vm.extract_elements(&value)?;
985-
for element in elements.into_iter().rev() {
986-
self.push_value(element);
987-
}
988-
Ok(None)
989-
}
990-
991981
fn jump(&self, label: bytecode::Label) {
992982
let target_pc = self.code.label_map[&label];
993983
#[cfg(feature = "vm-tracing-logging")]

0 commit comments

Comments
 (0)