-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for multi-level attribute for function call (#2794)
- Loading branch information
Showing
10 changed files
with
111 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,46 @@ | ||
from lpython import i32 | ||
class Person: | ||
def __init__(self:"Person", first:str, last:str, birthyear:i32, sgender:str): | ||
self.first:str = first | ||
self.last:str = last | ||
self.birthyear:i32 = birthyear | ||
self.sgender:str = sgender | ||
|
||
def describe(self:"Person"): | ||
print("first: " + self.first) | ||
print("last: " + self.last) | ||
print("birthyear: " + str(self.birthyear)) | ||
print("sgender: " + self.sgender) | ||
|
||
class Employee: | ||
def __init__(self:"Employee", person:Person, hire_date:i32, department:str): | ||
self.person:Person = person | ||
self.hire_date:i32 = hire_date | ||
self.department:str = department | ||
|
||
def describe(self:"Employee"): | ||
self.person.describe() | ||
print("hire_date: " + str(self.hire_date)) | ||
print("department: " + self.department) | ||
|
||
def main(): | ||
jack:Person = Person("Jack", "Smith", 1984, "M") | ||
jill_p:Person = Person("Jill", "Smith", 1984, "F") | ||
jill:Employee = Employee(jill_p, 2003, "sales") | ||
|
||
jack.describe() | ||
assert jack.first == "Jack" | ||
assert jack.last == "Smith" | ||
assert jack.birthyear == 1984 | ||
assert jack.sgender == "M" | ||
|
||
jill.describe() | ||
assert jill.person.first == "Jill" | ||
assert jill.person.last == "Smith" | ||
assert jill.person.birthyear == 1984 | ||
assert jill.person.sgender == "F" | ||
assert jill.department == "sales" | ||
assert jill.hire_date == 2003 | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -9,4 +9,4 @@ def __init__(self:"coord", x:i32, y:i32): | |
p2: coord = p1 | ||
p2.x = 2 | ||
print(p1.x) | ||
print(p2.x) | ||
print(p2.x) |
This file contains 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,13 @@ | ||
{ | ||
"basename": "asr-class01-4134616", | ||
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}", | ||
"infile": "tests/errors/class01.py", | ||
"infile_hash": "abc039698c8285a3831089abdd0cd9711894af57eb142d2222b3583d", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": null, | ||
"stdout_hash": null, | ||
"stderr": "asr-class01-4134616.stderr", | ||
"stderr_hash": "4f104cca0ef2ac39634223611165efee9d107c94292a98071d863ed0", | ||
"returncode": 2 | ||
} |
2 changes: 1 addition & 1 deletion
2
tests/reference/asr-class_04-b89178d.stderr → tests/reference/asr-class01-4134616.stderr
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
semantic error: Only Class constructor is allowed in the object assignment for now | ||
--> tests/errors/class_04.py:9:1 | ||
--> tests/errors/class01.py:9:1 | ||
| | ||
9 | p2: coord = p1 | ||
| ^^^^^^^^^^^^^^ |
This file was deleted.
Oops, something went wrong.
This file contains 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