mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 20:50:14 +01:00
Support passing positional args as keywords to bytecode functions.
For this, record argument names along with each bytecode function. The code still includes extensive debug logging support so far.
This commit is contained in:
35
tests/basics/fun-kwargs.py
Normal file
35
tests/basics/fun-kwargs.py
Normal file
@@ -0,0 +1,35 @@
|
||||
def f1(a):
|
||||
print(a)
|
||||
|
||||
f1(123)
|
||||
f1(a=123)
|
||||
try:
|
||||
f1(b=123)
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
def f2(a, b):
|
||||
print(a, b)
|
||||
|
||||
f2(1, 2)
|
||||
f2(a=3, b=4)
|
||||
f2(b=5, a=6)
|
||||
f2(7, b=8)
|
||||
try:
|
||||
f2(9, a=10)
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
def f3(a, b, *args):
|
||||
print(a, b, args)
|
||||
|
||||
|
||||
f3(1, b=3)
|
||||
try:
|
||||
f3(1, a=3)
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
try:
|
||||
f3(1, 2, 3, 4, a=5)
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
Reference in New Issue
Block a user