-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Truffle does not support function overloading #737
Comments
I'm getting the same issue +1 |
* master: Updated interface removed console.log Removed `allAssetsOf` in favor of `assetsOf` skipped test: truffle is broken trufflesuite/truffle#737 Added holder-centric getter tests Added require condition to assetByIndex
* master: Updated interface removed console.log Removed `allAssetsOf` in favor of `assetsOf` skipped test: truffle is broken trufflesuite/truffle#737 Added holder-centric getter tests Added require condition to assetByIndex
Facing the same issue, When would this be fixed? Any timeline? |
@etherwaifu Your solution does not work for me. It says |
Truffle doesn't work with overloaded functions. See: trufflesuite/truffle#569 trufflesuite/truffle#737
Yeah, calling overloaded functions in truffle seems to be borked... I changed from async/await:
back to:
and it was OK... Apparently the truffle fork (Neufund/truffle-contract@ecae099) works? (haven't tried) I even tried:
So, my solution is to use plain old JavaScript and abandon async/await syntax for now. |
@hynese This should be fixed on truffle's nightly for the next major version (darq-truffle on npm) which you can get by running:
It uses web3 1.0 under the hood so there are some breaking changes. Usage notes here. (If you try this feel free to ping with any problems, would love some early feedback on whether things are working in a production context). |
@vrogojin The workaround given by @etherwaifu for multiple arguments is incorrect and is not work for either. After debugging the code, I found that |
…ppInstance This addresses this bug we are getting in the CI coverage build: trufflesuite/truffle#737 The issue does not happen locally but using this solution does not break
In the meantime you can use web3.eth.sendTransaction and web3.eth.call to send your transactions
|
This is resolved via the |
I think it could still fail better: If I understand correctly, the first declared overload is used when you invoke Then there’s some code that (heuristically?) determines wether some of the arguments are DefaultBlockParameters (I’m sorry I don’t remember the name), and Yes, if you’re already aware of how accessing the overloaded methods work, such errors are easy to understand. But if you assume that overloaded functions just work, you’re going to have to fire up a debugger. I’m not saying this is a bug, just a usability issue that I imagine many people will run into. Maybe just add a hint about overloaded functions in the error message text? |
@gnidan we need more details |
@k06a do those docs help you? I'm having trouble making sense of what might be actionable here. Could someone write up some proposals for better error handling/reporting? Thanks! |
@gnidan yep, doc was helpful enough |
Just for your information, there are also some function overloading bugs in solidity compiler, which is about payable and non-payable functions with same names. You can find more details here: ethereum/solidity#526 I thought it was a truffle bug at first and followed this issue. But after wandering around for a while, I finally found out that it was a bug of solidity compiler. So I post it here and hope it can help others who may have the same issues of me. |
I didn't read the whole thread here but for me this is still not really fixed.
How is this supposed to work with function overloading? I have a method in two versions, with 2 parameters and with 3 parameters. If I use the version with 2 parameters in truffle console, then it actually tries to execute the version with 3 parameters. |
Not fixed for us too, trying to call a function with 1 parameter of type |
Can this be reopened please, this is not fixed. A fresh example is a failing build here erroring on
On top of that the error message is bad as it seems to be counting as parameter the And more specifically, using the syntax UPDATE: This is what works but feels too clumsy to be a proper solution
|
Just a note: we are currently working on a rewrite of Truffle contract that should fix this. |
I think it's fixed in Truffle v5:
Originally posted by @gnidan in #569 (comment) |
Ah so it looks like this is fixed, can we close this issue? |
So, the original issue of not having any overloading support has been fixed, but our overloading support still has significant limitations, leading to many of the comments above. That's why this issue has been left open; but perhaps instead we should close it and open a new one? |
I vote we close and open a new one (or several). |
OK, closing this in favor of #5061. |
Issue
Truffle fails with a
Error: Invalid number of arguments to Solidity function
error when testing an overloaded function.Steps to Reproduce
npm test
Expected Behavior
Tests should pass.
You can see that those tests work fine by changing the name of the overloaded function and using that name in the mentioned test cases.
Actual Results
Tests fail with a
Error: Invalid number of arguments to Solidity function
errorEnvironment
The text was updated successfully, but these errors were encountered: