I'm looking at a function that creates a local variable in an if statement. If someone called that function and the condition to the if statement was not triggered, that local variable wouldn't exist, right?

1 Answer 1


Yes. It's like other languages it won't exist in out of the scope. solc compiler give you Undeclared identifier error. for example

if (everything) {
   uint testVariable = 1;
require(testVariable == 1, "error"); // you will have Undeclared identifier error in here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.