You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to disable the ‘unused variable’ error or at least convert it into a warning. The error is triggered during the semantic analysis in the SymbolTableTraversal class so I added:
if(unusedSymbols.length!==0){unusedSymbols.forEach((symbol)=>{console.warn(`[Warning] Unused variable: ${symbol.name} in block`);});// throw new UnusedVariableError(unusedSymbols[0]);}
Removing the unused symbol using it's index from the tree (node.statements) resulted in the expected bytecode. (Only in block, not function/constructor params). One test failed as it expected a throw. I guess Jest’s spyOn can be used to expect a console.warn instead.
I’m curious if there’s been any further discussion on this. What’s the preferred approach here? Should unused variables be stripped from the bytecode, or should they remain? I noticed that Solidity keeps them in the bytecode unless the optimizer is enabled but cashscript's optimisations are enabled by default.
When debugging, it would be nice if errors like
Unused variable prefix at Line 71, Column 8
... could be a warnings instead of compilation error.
This allows for more easilly temporarily commenting out code.
The text was updated successfully, but these errors were encountered: