-
Notifications
You must be signed in to change notification settings - Fork 174
Default arguments not working ? #2109
Copy link
Copy link
Closed
Description
The following works in CP, but not LP.
from random import random
from lpython import (i8, i32, i64, f32, f64,
u8, u32,
TypeVar, Const,
dataclass,
# random
)
from numpy import (empty, sqrt, float32, float64,
int8, int32, array, # ndarray
)
def coin_flip(probability : f64=f64(0.5)) -> i8:
"""roll 1 bit"""
result : i8 = i8(0)
r : f64 = random()
if r < probability:
result = i8(1)
return result
def h() -> None:
i : i32
for i in range(10):
coin : i8 = coin_flip()
print(coin, end='')
print('')
if __name__ == "__main__":
h()(lp) ┌─(~/CLionProjects/lpython/lasr/LP-pycharm)─────────────────────────────────────────────────────────────────────────────────────────────────────────(brian@Golf37:s000)─┐
└─(11:36:44 on brian-lasr ✹ ✭)──> PYTHONPATH='../../src/runtime/lpython' python issue2107.py 1 ↵ ──(Wed,Jul05)─┘
1
1
1
1
1
0
1
1
0
0
(lp) ┌─(~/CLionProjects/lpython/lasr/LP-pycharm)─────────────────────────────────────────────────────────────────────────────────────────────────────────(brian@Golf37:s000)─┐
└─(11:36:49 on brian-lasr ✹ ✭)──> ~/CLionProjects/lpython/src/bin/lpython -I. issue2107.py ──(Wed,Jul05)─┘
semantic error: Number of arguments does not match in the function call
--> issue2107.py:26:21
|
26 | coin : i8 = coin_flip()
| ^^^^^^^^^^^ (found: '0', expected: '1')Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels