Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Remove restriction that contract names must match filenames #3

Closed
cag opened this issue Feb 10, 2017 · 6 comments
Closed

Remove restriction that contract names must match filenames #3

cag opened this issue Feb 10, 2017 · 6 comments

Comments

@cag
Copy link

cag commented Feb 10, 2017

solc 0.4.8 has some issues with source files which do not contain a contract or library with the same name as the filename. I recommend bumping the version of solc

From ConsenSys slack:

alanlu [6:05 PM]
Speaking of EthPM and ERC20, I have been getting this error: Could not find expected contract or library in 'example-package-standard-token/AbstractToken.sol': contract or library 'AbstractToken' not found.

[6:06]
Truffle v3.1.1 from NPM, using truffle install example-package-standard-token

[6:09]
Stuff compiles if I go into installed_contracts and rename Token to AbstractToken everywhere, but obviously, that's not a solution, so I was wondering if anybody knows about anything? As far as I can tell, Solidity docs do not suggest any naming restriction wrt contracts and filenames.

mike [6:10 PM]
@ alanlu this is a solc bug. Fixed in 0.4.9.

[6:10]
Which isn’t in Truffle yet.

@cag
Copy link
Author

cag commented Feb 10, 2017

Updates from Slack:

stefan.george [5:49 AM]
@ alanlu @ mike

Solidity docs do not suggest any naming restriction wrt contracts and filenames.

From truffle docs: http://truffleframework.com/docs/getting_started/compile#convention

...

alanlu [11:01 AM]
@stefan.george Wow, I was looking for that! Well, that is strictly on the Truffle side of things, and as I understand it, imports in Truffle are understood differently from imports in Solidity, which came after the feature was implemented in Truffle. Looks like I am mistaken, though the import semantic differences between vanilla Solidity and Truffle-flavored Solidity should be addressed. I will copy this over to the issue I posted.

@tcoulter
Copy link
Contributor

All of those issues are Truffle restrictions, and not related to the version of solidity. Upgrading solidity won’t fix those directly (although we might be able to use 0.4.9’s new output structure to fix some or all of these issues).

This is on my near-term roadmap. The restriction that a contract name must match the filename is an old restriction from the early days of Truffle, and should be able to be safely removed now.

@tcoulter
Copy link
Contributor

I'm going to rename this to "Remove restriction that contract names must match file names"

@tcoulter tcoulter changed the title Upgrade solc Remove restriction that contract names must match filenames Feb 10, 2017
@tcoulter
Copy link
Contributor

mike [6:10 PM]
@ alanlu this is a solc bug. Fixed in 0.4.9.

Let me rephrase the above: Mike was mistaken - it's not a solc bug, but solc 0.4.9 might let us fix it.

I'm wary of upgrading to solc 0.4.9 given that I've been told "there's issues", mostly by @pipermerriam, and the last thing I want to do is release those issues onto Truffle users. I hope to better evaluate it soon.

@cag
Copy link
Author

cag commented Feb 10, 2017

Thanks for the clarification. This probably belongs more in the main truffle repo issue tracker then...

Though I've noticed that the update wasn't #pragma'd in the AbstractToken.sol containing Token, so it is very possible that 0.4.9 is not necessary for fixing this issue.

@tcoulter
Copy link
Contributor

This restriction has been removed in 3.1.9 beta. Your feedback welcome. More details here: https://github.com/ConsenSys/truffle/releases/tag/3.1.9

Note that it was a quick beta release (getting on a plane today) so if you can try it out for your context that'd be great. Remember: Betas are supposed to bake. The cooking time on this one might be a week or two. Would love for you guys to try out the use case again above with the new beta and tell me what you think.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants