Skip to content

Commit 5602724

Browse files
committed
compile: implement Ellipsis
1 parent 43c7838 commit 5602724

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

compile/compile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@ func (c *compiler) Expr(expr ast.Expr) {
16121612
// Value Singleton
16131613
c.LoadConst(node.Value)
16141614
case *ast.Ellipsis:
1615-
panic("FIXME compile: Ellipsis not implemented")
1615+
c.LoadConst(py.Ellipsis)
16161616
case *ast.Attribute:
16171617
// Value Expr
16181618
// Attr Identifier

compile/compile_data_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3824,4 +3824,21 @@ var compileTestData = []struct {
38243824
Firstlineno: 1,
38253825
Lnotab: "",
38263826
}, nil, ""},
3827+
{"...", "exec", &py.Code{
3828+
Argcount: 0,
3829+
Kwonlyargcount: 0,
3830+
Nlocals: 0,
3831+
Stacksize: 1,
3832+
Flags: 64,
3833+
Code: "\x64\x00\x00\x01\x64\x01\x00\x53",
3834+
Consts: []py.Object{py.Ellipsis, py.None},
3835+
Names: []string{},
3836+
Varnames: []string{},
3837+
Freevars: []string{},
3838+
Cellvars: []string{},
3839+
Filename: "<string>",
3840+
Name: "<module>",
3841+
Firstlineno: 1,
3842+
Lnotab: "",
3843+
}, nil, ""},
38273844
}

compile/make_compile_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ def f():
361361
def f():
362362
yield from range(10)
363363
''', "exec"),
364+
# ellipsis
365+
('''...''', "exec"),
364366
]
365367

366368
def string(s):
@@ -419,6 +421,8 @@ def const(x):
419421
])
420422
elif x is None:
421423
return 'py.None'
424+
elif x is ...:
425+
return 'py.Ellipsis'
422426
else:
423427
raise AssertionError("Unknown const %r" % x)
424428

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy