-
Notifications
You must be signed in to change notification settings - Fork 126
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
fix: support T
and T?
methods with the same name
#1758
Closed
Closed
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
974769b
fix: clash of methods for non-optional and optional types
i582 7b1dd54
fix
i582 ec4bb5b
fix wrappers
i582 646a6c7
added tests
i582 c8ee339
added entry to CHANGELOG.md
i582 1a402bd
use "optional" instead of "nullable"
i582 3ba5eb5
fix
i582 637ca1a
fix
i582 5acd4d1
added comment
i582 c0cc333
update snapshots
i582 dd16917
Merge branch 'main' into pmakhnev/optional-methods
anton-trunov 111f278
fix internal compiler error
i582 d134624
Merge branch 'main' into pmakhnev/optional-methods
i582 1806767
fix
i582 341f7c7
fix
i582 04a8ec8
revert pre-push
i582 c352344
fix eslint issue
i582 2168fd2
Merge branch 'main' into pmakhnev/optional-methods
anton-trunov 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
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
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
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,34 @@ | ||
struct SomeStruct { i: Int; b: Bool } | ||
|
||
extends fun equal(self: SomeStruct?, other: SomeStruct?): Bool { | ||
if (self == null && other == null) { return true } | ||
if (self == null || other == null) { return false } | ||
return self!!.i == other!!.i && self!!.b == other!!.b; | ||
} | ||
|
||
extends fun equal(self: SomeStruct, other: SomeStruct): Bool { | ||
return self.i == other.i && self.b == other.b; | ||
} | ||
|
||
contract Opt5 { | ||
receive() { } | ||
|
||
get fun test1(): Bool { | ||
let s1 = SomeStruct {i: 42, b: true}; | ||
let s2 = SomeStruct {i: 42, b: false}; | ||
return s1.equal(s1) | ||
} | ||
|
||
get fun test2(): Bool { | ||
let s1 = SomeStruct {i: 42, b: true}; | ||
let s2 = SomeStruct {i: 42, b: false}; | ||
let s3: SomeStruct? = null; | ||
return s1.equal(s1) && !s3.equal(s2); | ||
} | ||
|
||
get fun test3(): Bool { | ||
let s1: SomeStruct? = null; | ||
let s2: SomeStruct? = null; | ||
return !s1.equal(s2); | ||
} | ||
} |
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,37 @@ | ||
import { toNano } from "@ton/core"; | ||
import { Blockchain, SandboxContract, TreasuryContract } from "@ton/sandbox"; | ||
import { Opt5 } from "./contracts/output/optionals-3_Opt5"; | ||
import "@ton/test-utils"; | ||
|
||
describe("optionals", () => { | ||
let blockchain: Blockchain; | ||
let treasure: SandboxContract<TreasuryContract>; | ||
let contract: SandboxContract<Opt5>; | ||
|
||
beforeEach(async () => { | ||
blockchain = await Blockchain.create(); | ||
blockchain.verbosity.print = false; | ||
treasure = await blockchain.treasury("treasure"); | ||
|
||
contract = blockchain.openContract(await Opt5.fromInit()); | ||
|
||
const deployResult = await contract.send( | ||
treasure.getSender(), | ||
{ value: toNano("10") }, | ||
null, | ||
); | ||
|
||
expect(deployResult.transactions).toHaveTransaction({ | ||
from: treasure.address, | ||
to: contract.address, | ||
success: true, | ||
deploy: true, | ||
}); | ||
}); | ||
|
||
it("should calculate correct result", async () => { | ||
expect(await contract.getTest1()).toEqual(true); | ||
expect(await contract.getTest2()).toEqual(true); | ||
expect(await contract.getTest3()).toEqual(false); | ||
}); | ||
}); |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, this wouldn't fail at runtime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, now we just generate the qualifier expression as is, so
mp.asCell()
becomesmp
in the FunC code:tact/src/abi/map.ts
Line 374 in 7b1dd54
Thus,
asCell
simply returns non optionalCell
type