Waffle
Waffle copied to clipboard
Waffle tries to resolve commented imports
The following will fail to compile with error: Error: None of the sub-resolvers resolved "./NonExistent.sol" location.
pragma solidity ^0.5.7;
// import "./NonExistent.sol";
I just ran into this issue as well, stumped me for a few minutes
The issue at hand is caused by the regex in the resolver project.
I've written a regex that omits comments (both inline and multiline) and includes curly bracket notation in imports e.g import { A, B, C as D } from "./alphabet.sol";. However, it's hard for regex, in this case, to take into consideration escaped characters and on top of that, it's not entirely safe due to backreferencing/backtracing. It would be much better to use a solidity parser instead of a regex.
My regex: /^\s*import(?:\s+|(?:\s*(?:\/{2})+.*?\s+)*|(?:\s*\/\*.*?\*\/\s+)*)(?:(?:'([^\n\r]+)')|(?:"([^\n\r]+)")|(?:{\s*[^\n\r]+\s*})|(?:\*|\w+))(?:\s+as\s+\w+)?(?:\s+from\s+(?:(?:'([^\n\r]+)')|(?:"([^\n\r]+)")))?;/gms