-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize AtomConstructor's fields via local vars
The mechanism follows a similar approach to what is being in functions with default arguments. Additionally since InstantiateAtomNode wasn't a subtype of EnsoRootNode it couldn't be used in the application, which was the primary reason for issue #181449213. Alternatively InstantiateAtomNode could have been enhanced to extend EnsoRootNode rather than RootNode to carry scope info but the former seemed simpler. See test cases for previously crashing and invalid cases.
- Loading branch information
Showing
6 changed files
with
130 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,4 +128,5 @@ protected boolean isInstrumentable() { | |
public boolean isCloningAllowed() { | ||
return true; | ||
} | ||
|
||
} |
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
58 changes: 0 additions & 58 deletions
58
...ntime/src/main/java/org/enso/interpreter/node/expression/builtin/InstantiateAtomNode.java
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
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,42 @@ | ||
from Standard.Base import all | ||
import Standard.Test | ||
|
||
type Box | ||
type Foo (v : Bool = True) | ||
|
||
type Bar (a : Integer = 1) (b : Box = (Foo False)) | ||
|
||
type A a=0 b=1 | ||
type B a=2 b=(Foo True) | ||
type C a=3 b=Foo | ||
type D a=4 b=(Bar 1) | ||
type E a=5 b=a c=(b+1) | ||
type F a=6 b=(Foo False) c=(b.v) | ||
#type D a=4 b=Bar // will crash | ||
|
||
spec = | ||
Test.group "Atom Constructors" <| | ||
Test.specify "should be allowed to use primitive default arguments" <| | ||
x = A 1 | ||
x.b.should_equal 1 | ||
y = A 1 | ||
y.b.should_equal 1 | ||
|
||
Test.specify "should be allowed to use non-primitive default arguments" <| | ||
a = B 1 (Foo False) | ||
a.b.should_equal (Foo False) | ||
b = B 1 | ||
b.b.should_equal (Foo True) | ||
c = C 1 | ||
c.b.should_equal (Foo) | ||
d = D 1 | ||
d.b.b.should_equal (Foo False) | ||
|
||
Test.specify "should be allowed to use default arguments that refer to previous parameters" <| | ||
e = E 1 | ||
e.b.should_equal 1 | ||
e.c.should_equal 2 | ||
f = F 1 | ||
f.c.should_equal False | ||
|
||
main = Test.Suite.run_main here.spec |