Fixup more kwargs stuff, need to pop values for defaults
This commit is contained in:
parent
2f78ae8770
commit
a4a4da70df
@ -773,6 +773,7 @@ static void function(FunctionType type, size_t blockWidth) {
|
||||
namedVariable(synth, 0);
|
||||
emitBytes(OP_CALL, 0);
|
||||
EMIT_CONSTANT_OP(OP_SET_LOCAL, myLocal);
|
||||
emitByte(OP_POP); /* local value */
|
||||
endScope();
|
||||
/* Otherwise pop the comparison. */
|
||||
patchJump(jumpIndex);
|
||||
@ -799,6 +800,7 @@ static void function(FunctionType type, size_t blockWidth) {
|
||||
beginScope();
|
||||
expression(); /* Read expression */
|
||||
EMIT_CONSTANT_OP(OP_SET_LOCAL, myLocal);
|
||||
emitByte(OP_POP); /* local value */
|
||||
endScope();
|
||||
patchJump(jumpIndex);
|
||||
emitByte(OP_POP);
|
||||
|
@ -1,15 +1,21 @@
|
||||
def anything(*args, **kwargs):
|
||||
def foo():
|
||||
print("hi")
|
||||
print("Positionals:", args)
|
||||
print("Keywords:", kwargs)
|
||||
return foo
|
||||
|
||||
anything(1,2,3,"a","b",foo="bar",biz=42)
|
||||
anything(1,2,3,"a","b",foo="bar",biz=42)()
|
||||
|
||||
anything()()
|
||||
|
||||
def func(a,b,*args,**kwargs):
|
||||
print(a, b, args)
|
||||
let x = 'hello'
|
||||
print(x)
|
||||
return x
|
||||
|
||||
func(1,2,3,4,5,6,foo="bar")
|
||||
print(func(1,2,3,4,5,6,foo="bar"))
|
||||
|
||||
def last(a,b,c=1,d=2,**kwargs):
|
||||
print("Main:", a, b, c, d)
|
||||
|
@ -1,7 +1,12 @@
|
||||
Positionals: [1, 2, 3, 'a', 'b']
|
||||
Keywords: {'biz': 42, 'foo': 'bar'}
|
||||
hi
|
||||
Positionals: []
|
||||
Keywords: {}
|
||||
hi
|
||||
1 2 [3, 4, 5, 6]
|
||||
hello
|
||||
hello
|
||||
Main: 1 2 1 2
|
||||
Keyword: {}
|
||||
Main: 1 2 7 3
|
||||
|
@ -1,7 +1,10 @@
|
||||
def foo(default="bacon"):
|
||||
print("You like",default,"right?")
|
||||
def test():
|
||||
print("hello")
|
||||
return test
|
||||
|
||||
foo()
|
||||
print(foo())
|
||||
foo("sports")
|
||||
|
||||
def fillValues(a=1,b=2,c="c",d=None,e=2.71828):
|
||||
|
@ -1,4 +1,5 @@
|
||||
You like bacon right?
|
||||
<function test>
|
||||
You like sports right?
|
||||
1 True c None 2.71828
|
||||
one 2 test None <type 'object'>
|
||||
|
Loading…
Reference in New Issue
Block a user