forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw an error for class objects assignment (lcompilers#2784)
- Loading branch information
Showing
5 changed files
with
61 additions
and
18 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,12 @@ | ||
from lpython import i32 | ||
|
||
class coord: | ||
def __init__(self:"coord", x:i32, y:i32): | ||
self.x: i32 = x | ||
self.y: i32 = y | ||
|
||
p1: coord = coord(1, 2) | ||
p2: coord = p1 | ||
p2.x = 2 | ||
print(p1.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-class_04-b89178d", | ||
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}", | ||
"infile": "tests/errors/class_04.py", | ||
"infile_hash": "e1e1c48050cce1b2855e4f8409aa3d72df716f61b8aa045aa97ae914", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": null, | ||
"stdout_hash": null, | ||
"stderr": "asr-class_04-b89178d.stderr", | ||
"stderr_hash": "7f8e807f5582952b4ad93b1fb3d4d264842a0700aeda5be00611d098", | ||
"returncode": 2 | ||
} |
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,5 @@ | ||
semantic error: Only Class constructor is allowed in the object assignment for now | ||
--> tests/errors/class_04.py:9:1 | ||
| | ||
9 | p2: coord = p1 | ||
| ^^^^^^^^^^^^^^ |
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