Using libraries leaves behind a library link reference in the binary
which the linker must later resolve. These link references were still
being generated by name and not by fully-qualified name. This would
lead to a link-time collision between two libraries having the same
name but in different source units.
This change changes linker symbols over to fully-qualified names,
which resolves that issue. This does potentially introduce a new
problem, which is that linker symbols appear to be limited to 36
characters and are truncated. Storing paths extends the average
symbol size, and it would be great if truncation was from the tail
rather than the head.
Because contracts are uniquely identified by their source unit, there
is no need for a unique error for this; it's actually covered by the
checker for double-declaration of identifiers.
Throwing a CompilerError on multiple contract definition violates the
expectations of the test suite, which thinks that compile() will
return false if the code can't compile. This brings contract
collision reporting in line with most of the other errors.
A large number of tests compile contracts while passing in an empty
string for the source name. This leads to it being keyed by the name
":<contract>", while the tests try to look it up under the name
"<contract>". This change resolves that issue by dropping the ':' in
cases where there is, effectively, no source file to prepend anyway.
@chriseth had suggested that it would be better if contracts were
referenced in a file:contract notation, and that we output .bin files
that prepend original path names if necessary to avoid a collision.
This commit is mostly a draft; it still needs to be run through the test
suite.
The previous behaviour, courtesy of the [] operator in std::map, would
uncritically store a new ContractDefinition in m_contracts even when a
ContractDefinition already existed. This "resolved" collissions on contract
names by clobbering the original one with the new one, and could lead to
scenarios where the clobber would only be discovered when the original
ContractDefinition could not be found or referred to, which was an unhelpful
InternalCompilerError.
This change checks the m_contracts map for a collision first and will not let
the ContractDefinition be changed to a new one once it's set, throwing a
CompilerError with information about the conflict.