mirror of https://github.com/mtshiba/pylyzer
fix: slice bug
This commit is contained in:
parent
deb6736f9f
commit
0da66dceca
|
|
@ -1886,6 +1886,7 @@ impl ASTConverter {
|
||||||
);
|
);
|
||||||
method.call1(self.convert_expr(*subs.slice))
|
method.call1(self.convert_expr(*subs.slice))
|
||||||
}
|
}
|
||||||
|
// [:] == [slice(None)]
|
||||||
// [start:] == [slice(start, None)]
|
// [start:] == [slice(start, None)]
|
||||||
// [:stop] == [slice(stop)]
|
// [:stop] == [slice(stop)]
|
||||||
// [start:stop] == [slice(start, stop)]
|
// [start:stop] == [slice(start, stop)]
|
||||||
|
|
@ -1905,6 +1906,14 @@ impl ASTConverter {
|
||||||
if let Some(step) = step {
|
if let Some(step) = step {
|
||||||
args.push_pos(PosArg::new(step));
|
args.push_pos(PosArg::new(step));
|
||||||
}
|
}
|
||||||
|
if args.is_empty() {
|
||||||
|
args.push_pos(PosArg::new(Expr::Literal(Literal::new(Token::new(
|
||||||
|
TokenKind::NoneLit,
|
||||||
|
"None",
|
||||||
|
loc.row.get(),
|
||||||
|
loc.column.to_zero_indexed(),
|
||||||
|
)))));
|
||||||
|
}
|
||||||
let slice = self.convert_ident("slice".to_string(), loc);
|
let slice = self.convert_ident("slice".to_string(), loc);
|
||||||
slice.call(args).into()
|
slice.call(args).into()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
l = [1, 2, 3]
|
l = [1, 2, 3]
|
||||||
_ = l[1:2]
|
_ = l[1:2]
|
||||||
|
_ = l[:]
|
||||||
|
_ = l[1:]
|
||||||
|
_ = l[:1]
|
||||||
|
_ = l[1:1:1]
|
||||||
print(l[2])
|
print(l[2])
|
||||||
print(l["a"]) # ERR
|
print(l["a"]) # ERR
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue