-
Notifications
You must be signed in to change notification settings - Fork 174
Function Default Arguments #2618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ubaidsk
merged 40 commits into
lcompilers:main
from
assem2002:function_default_arguments
May 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
1a2e739
Fixed Issue #2042
assem2002 1adbddc
Fixed issue #2042 - dispatched the type of list and dict
assem2002 9fbd33e
Fix Warning :UnInitialized Vec
assem2002 0e14c0a
Fixed Issue #2042
assem2002 abcd34a
Fixed issue #2042 - dispatched the type of list and dict
assem2002 d7869b1
Fixed Issue #2042
assem2002 fa18fa7
Fixed issue #2042 - dispatched the type of list and dict
assem2002 7f85dc2
Default Arguments Implemented
assem2002 649b079
Default_argumets_implemented -removed other branch edit
assem2002 2902eea
setting loc makes a serious problem with complex()
assem2002 d3734db
handled function call without apearent argument passed
assem2002 f8b7c97
removed print statement usedin debugging
assem2002 c4ac4f3
added proper handling for nullptr values (they won't break the code a…
assem2002 1f3d26f
minor edit
assem2002 2cf7f4f
handled problem in creating c code (c dosen't support default arguments)
assem2002 35b5faa
Apply suggestions from code review
assem2002 a4d4d9c
applied code review changes (by Shaikh Ubaid)
assem2002 8ec5b38
added integration test for function default arguments
assem2002 3bb336c
added the 'def_func_01.py' to cmake testing list
assem2002 c7ff531
searching in symbol table for default arguments
assem2002 3423d9b
Update src/lpython/semantics/python_ast_to_asr.cpp
assem2002 8748b42
Fixed Issue #2042
assem2002 be236f8
Fixed issue #2042 - dispatched the type of list and dict
assem2002 c286d39
Fixed issue #2042 - dispatched the type of list and dict
assem2002 b34a32b
added test_00
assem2002 11d1015
solved minor problem with previous commits
assem2002 ee07640
fixed some indentations in def_func_01.py test file
assem2002 fe4f162
Update src/lpython/semantics/python_ast_to_asr.cpp
assem2002 ae0f7a0
Fixed Issue #2042
assem2002 233eddd
Fixed issue #2042 - dispatched the type of list and dict
assem2002 b86819a
Fixed issue #2042 - dispatched the type of list and dict
assem2002 d912b71
added semantic error for insufficient arguments + some edits
assem2002 4860230
resolved minor problems
assem2002 7ca1987
minor edit
assem2002 0fee905
Update src/lpython/semantics/python_ast_to_asr.cpp
assem2002 fc1d61c
added reference tests
assem2002 262041a
minor edit
assem2002 b8a14b1
minor edit
assem2002 a474734
Update integration_tests/CMakeLists.txt
assem2002 2549f0b
typo edits
assem2002 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
added integration test for function default arguments
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| from lpython import i32,i64 | ||
|
|
||
| def factorial_1(x: i32, y:i32 =1) ->i32 : | ||
| if x <= 1: | ||
| return y | ||
| return x * factorial_1(x-1) | ||
|
|
||
| def factorial_2(x: i32, y:i32=3 ,z:i32 =2) ->i32: | ||
| if x ==4: | ||
| return x * y * z | ||
| return x * factorial_2(x-1) | ||
|
|
||
| def default_func(x : str ="Hello" ,y : str = " ", z : str = "World") ->str: | ||
| return x + y + z | ||
|
|
||
|
|
||
| def even_positons(iterator : i32 , to_add : str = "?")-> str: | ||
| if (iterator == 10): return "" | ||
|
|
||
| if iterator%2 == 0 : | ||
| return to_add + even_positons(iterator+1,"X") | ||
|
|
||
| return to_add +even_positons(iterator+1) | ||
|
|
||
|
|
||
|
|
||
assem2002 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def test_all(): | ||
|
|
||
| test_01 : i32 = factorial_1(5,0) | ||
| print("test_01 is =>",test_01) | ||
| assert test_01 == 120 | ||
|
|
||
| test_02 : i32 = factorial_1(1,5555) | ||
| print("test_02 is =>",test_02) | ||
| assert test_02 == 5555 | ||
assem2002 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test_03 : i32 =factorial_2(5,99999,99999) | ||
| print("test_03 is =>",test_03) | ||
| assert test_03 == 120 | ||
|
|
||
| test_04 : i32 = factorial_2(4,-1,100) | ||
| print("test_04 is =>",test_04) | ||
| assert test_04 == -400 | ||
|
|
||
| test_05 :str = default_func() | ||
| print("test_05 is =>",test_05) | ||
| assert test_05 == "Hello World" | ||
|
|
||
| test_06 :str = default_func(y = "|||",x="Hi") | ||
| print("test_06 is =>",test_06) | ||
| assert test_06 == "Hi|||World" | ||
|
|
||
| test_07 : str = even_positons(0) | ||
| print("test_07 is =>",test_07) | ||
| assert test_07 == "?X?X?X?X?X" | ||
|
|
||
| test_08 : str = even_positons(0,"W") | ||
| print("test_08 is =>",test_08) | ||
| assert test_08 == "WX?X?X?X?X" | ||
|
|
||
| test_all() | ||
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
assem2002 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.