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))
|
||||
}
|
||||
// [:] == [slice(None)]
|
||||
// [start:] == [slice(start, None)]
|
||||
// [:stop] == [slice(stop)]
|
||||
// [start:stop] == [slice(start, stop)]
|
||||
|
|
@ -1905,6 +1906,14 @@ impl ASTConverter {
|
|||
if let Some(step) = 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);
|
||||
slice.call(args).into()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
l = [1, 2, 3]
|
||||
_ = l[1:2]
|
||||
_ = l[:]
|
||||
_ = l[1:]
|
||||
_ = l[:1]
|
||||
_ = l[1:1:1]
|
||||
print(l[2])
|
||||
print(l["a"]) # ERR
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue