`Identifier already declared` error
x676f64 opened this issue · 4 comments
Hmm, that's weird 🤔 This should throw a declaration error the first time you re-declare a variable.
I don't seem to be able to reproduce this. Could it be that the error is delayed from the first instance of the re-declaration? (maybe delayed by ganache; error location matches mine in the screenshot). Can you check the output of .dump
after you re-declare b
(this is what's being evaluated)?
Also, note that delete <var>
will reset its value to default (zero for unit) and not undeclare it. You'll still get a declaration error if you attempt to declare the variable again.
Sure, here you go. It appears you're right. It's just not triggering an error the first time.
🚀 Entering interactive Solidity shell. '.help' and '.exit' are your friends.
» ℹ️ ganache-mgr: starting temp. ganache instance ...
»
» uint a = 1101*10**18
» uint b = 310*10**18
» a/b
3
» uint a = 11*10**22
» uint b = 310*10**22
[
{
component: 'general',
errorCode: '2333',
formattedMessage: 'DeclarationError: Identifier already declared.\n' +
'Note: The previous declaration is here:\n' +
'\n',
message: 'Identifier already declared.',
secondarySourceLocations: [ [Object] ],
severity: 'error',
sourceLocation: { end: 219, file: '', start: 213 },
type: 'DeclarationError'
}
]
» .dump
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.7;
contract MainContract {
function main() public {
uint a = 1101*10**18;
uint b = 310*10**18;
a/b;
return ;
}
}
Hey 🙌 ,
just published a new version that may fix an issue where an error wasn't returned even though it should. Can you give it a try?
Else, would be great if you could just run ganache-cli
in another shell window, keep the console open. then start solidity-shell
which should connect to your running ganache instance. Now try to reproduce the issue and check if there is a delay between solidity-shell and the ganache rpc calls. It does not reproduce on my local machine (macos) but if we can track it down I might be able to check what's going wrong :)
cheers
I'm closing this for now. feel free to reopen if you have more information on how to reproduce. thanks!