forked from Rust-related/RustPython
Merge pull request #4957 from youknowone/Located-start
more location -> start()
This commit is contained in:
@@ -554,7 +554,7 @@ impl Compiler {
|
||||
|
||||
fn compile_statement(&mut self, statement: &ast::Stmt) -> CompileResult<()> {
|
||||
trace!("Compiling {:?}", statement);
|
||||
self.set_source_location(statement.location);
|
||||
self.set_source_location(statement.start());
|
||||
use ast::StmtKind::*;
|
||||
|
||||
match &statement.node {
|
||||
@@ -598,8 +598,9 @@ impl Compiler {
|
||||
|
||||
let from_list = if import_star {
|
||||
if self.ctx.in_func() {
|
||||
return Err(self
|
||||
.error_loc(CodegenErrorType::FunctionImportStar, statement.location));
|
||||
return Err(
|
||||
self.error_loc(CodegenErrorType::FunctionImportStar, statement.start())
|
||||
);
|
||||
}
|
||||
vec![ConstantData::Str {
|
||||
value: "*".to_owned(),
|
||||
@@ -800,7 +801,7 @@ impl Compiler {
|
||||
emit!(self, Instruction::Break { target: end });
|
||||
}
|
||||
None => {
|
||||
return Err(self.error_loc(CodegenErrorType::InvalidBreak, statement.location));
|
||||
return Err(self.error_loc(CodegenErrorType::InvalidBreak, statement.start()));
|
||||
}
|
||||
},
|
||||
Continue => match self.ctx.loop_data {
|
||||
@@ -809,13 +810,13 @@ impl Compiler {
|
||||
}
|
||||
None => {
|
||||
return Err(
|
||||
self.error_loc(CodegenErrorType::InvalidContinue, statement.location)
|
||||
self.error_loc(CodegenErrorType::InvalidContinue, statement.start())
|
||||
);
|
||||
}
|
||||
},
|
||||
Return { value } => {
|
||||
if !self.ctx.in_func() {
|
||||
return Err(self.error_loc(CodegenErrorType::InvalidReturn, statement.location));
|
||||
return Err(self.error_loc(CodegenErrorType::InvalidReturn, statement.start()));
|
||||
}
|
||||
match value {
|
||||
Some(v) => {
|
||||
@@ -825,10 +826,8 @@ impl Compiler {
|
||||
.flags
|
||||
.contains(bytecode::CodeFlags::IS_GENERATOR)
|
||||
{
|
||||
return Err(self.error_loc(
|
||||
CodegenErrorType::AsyncReturnValue,
|
||||
statement.location,
|
||||
));
|
||||
return Err(self
|
||||
.error_loc(CodegenErrorType::AsyncReturnValue, statement.start()));
|
||||
}
|
||||
self.compile_expression(v)?;
|
||||
}
|
||||
@@ -1487,7 +1486,7 @@ impl Compiler {
|
||||
|
||||
match &item.optional_vars {
|
||||
Some(var) => {
|
||||
self.set_source_location(var.location);
|
||||
self.set_source_location(var.start());
|
||||
self.compile_store(var)?;
|
||||
}
|
||||
None => {
|
||||
@@ -1763,7 +1762,7 @@ impl Compiler {
|
||||
.ok_or_else(|| {
|
||||
self.error_loc(
|
||||
CodegenErrorType::TooManyStarUnpack,
|
||||
target.location,
|
||||
target.start(),
|
||||
)
|
||||
})?;
|
||||
let args = bytecode::UnpackExArgs { before, after };
|
||||
@@ -2038,7 +2037,7 @@ impl Compiler {
|
||||
|
||||
fn compile_expression(&mut self, expression: &ast::Expr) -> CompileResult<()> {
|
||||
trace!("Compiling {:?}", expression);
|
||||
self.set_source_location(expression.location);
|
||||
self.set_source_location(expression.start());
|
||||
|
||||
use ast::ExprKind::*;
|
||||
match &expression.node {
|
||||
|
||||
@@ -608,7 +608,7 @@ impl SymbolTableBuilder {
|
||||
} else {
|
||||
SymbolUsage::Parameter
|
||||
};
|
||||
self.register_name(¶meter.node.arg, usage, parameter.location)
|
||||
self.register_name(¶meter.node.arg, usage, parameter.start())
|
||||
}
|
||||
|
||||
fn scan_parameters_annotations(&mut self, parameters: &[ast::Arg]) -> SymbolTableResult {
|
||||
@@ -635,7 +635,7 @@ impl SymbolTableBuilder {
|
||||
|
||||
fn scan_statement(&mut self, statement: &ast::Stmt) -> SymbolTableResult {
|
||||
use ast::StmtKind::*;
|
||||
let location = statement.location;
|
||||
let location = statement.start();
|
||||
if let ImportFrom { module, names, .. } = &statement.node {
|
||||
if module.as_deref() == Some("__future__") {
|
||||
for feature in names {
|
||||
@@ -867,7 +867,7 @@ impl SymbolTableBuilder {
|
||||
context: ExpressionContext,
|
||||
) -> SymbolTableResult {
|
||||
use ast::ExprKind::*;
|
||||
let location = expression.location;
|
||||
let location = expression.start();
|
||||
match &expression.node {
|
||||
BinOp { left, right, .. } => {
|
||||
self.scan_expression(left, context)?;
|
||||
@@ -1004,7 +1004,7 @@ impl SymbolTableBuilder {
|
||||
}
|
||||
}
|
||||
Lambda { args, body } => {
|
||||
self.enter_function("lambda", args, expression.location.row())?;
|
||||
self.enter_function("lambda", args, expression.start().row())?;
|
||||
match context {
|
||||
ExpressionContext::IterDefinitionExp => {
|
||||
self.scan_expression(body, ExpressionContext::IterDefinitionExp)?;
|
||||
|
||||
Reference in New Issue
Block a user