-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support use of constant in other constant and for struct field d…
…efault value before declaration (#1478) * fix: support use of constant in other constant and for struct field default value before declaration Fixes #1477 Fixes #879 * added CHANGELOG.md entry * fixed review issues and added more positive tests * use `??=` * fix * merge * fixed review issues * fixed review issue * fixed review issue * fixed review issue
- Loading branch information
Showing
16 changed files
with
305 additions
and
26 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
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
7 changes: 7 additions & 0 deletions
7
...compilation-failed/contracts/const-eval-constant-circular-dependency-self-assignment.tact
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,7 @@ | ||
const A: Int = A; | ||
|
||
contract Test { | ||
get fun getConstant(): Int { | ||
return A; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ailed/contracts/const-eval-constant-circular-dependency-with-deep-recursive-function.tact
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,15 @@ | ||
const A: Int = foo(20); | ||
const C: Int = A; | ||
|
||
fun foo(value: Int): Int { | ||
if (value > 1) { | ||
return foo(value - 1) | ||
} | ||
return C; | ||
} | ||
|
||
contract Test { | ||
get fun getConstant(): Int { | ||
return C; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...t/compilation-failed/contracts/const-eval-constant-circular-dependency-with-function.tact
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 @@ | ||
const A: Int = foo(); | ||
const C: Int = A; | ||
|
||
fun foo(): Int { | ||
return C; | ||
} | ||
|
||
contract Test { | ||
get fun getConstant(): Int { | ||
return C; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
.../compilation-failed/contracts/const-eval-constant-circular-dependency-with-functions.tact
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,20 @@ | ||
const A: Int = foo(); | ||
const C: Int = A; | ||
|
||
fun foo(): Int { | ||
return bar() | ||
} | ||
|
||
fun bar(): Int { | ||
return baz() | ||
} | ||
|
||
fun baz(): Int { | ||
return C | ||
} | ||
|
||
contract Test { | ||
get fun getConstant(): Int { | ||
return C; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ion-failed/contracts/const-eval-constant-circular-dependency-with-recursive-function.tact
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,15 @@ | ||
const A: Int = foo(3); | ||
const C: Int = A; | ||
|
||
fun foo(value: Int): Int { | ||
if (value > 1) { | ||
return foo(value - 1) | ||
} | ||
return C; | ||
} | ||
|
||
contract Test { | ||
get fun getConstant(): Int { | ||
return C; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/test/compilation-failed/contracts/const-eval-constant-circular-dependency.tact
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,8 @@ | ||
const A: Int = C; | ||
const C: Int = A; | ||
|
||
contract Test { | ||
get fun getConstant(): Int { | ||
return C; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/test/compilation-failed/contracts/const-eval-constant-deep-circular-dependency.tact
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,11 @@ | ||
const A: Int = E; | ||
const B: Int = A; | ||
const C: Int = B; | ||
const D: Int = C; | ||
const E: Int = D; | ||
|
||
contract Test { | ||
get fun getConstant(): Int { | ||
return E; | ||
} | ||
} |
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
Oops, something went wrong.