trufflesuite / truffle

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
14.02k stars 2.32k forks source link

Truffle compile error with multiline imports #3815

Closed chancehudson closed 3 years ago

chancehudson commented 3 years ago

Issue

Compilation fails as a result of an invalid regular expression.

Steps to Reproduce

Running these shell commands will reproduce the error.

Specifically the error is occurring when compiling this solidity code.

This is the section of truffle throwing the error. This is the message that is output by solc (and then used to construct the regex). All the import statements in the error from solc have strange unicode characters at the beginning.

Source "(�aries/Types.sol" not found: Callback not supported. ParsedContract.sol:9:1: ParserError: Source "(�aries/Types.sol" not found: Callback not supported.
import {
^ (Relevant source part starts here and spans across multiple lines).

This issue is new with 5.1.66.

Expected Behavior

The code compiles without error.

Actual Results

SyntaxError: Invalid regular expression: /("|')(.*(�aries/Types.sol)("|')/: Unterminated group
    at new RegExp (<anonymous>)
    at /zkopru/node_modules/truffle/build/webpack:/packages/compile-solidity/parser.js:63:1
    at Array.map (<anonymous>)
    at Object.parseImports (/zkopru/node_modules/truffle/build/webpack:/packages/compile-solidity/parser.js:53:1)
    at parseImports (/zkopru/node_modules/truffle/build/webpack:/packages/compile-solidity/profiler/loadParser.js:24:1)
    at Object.<anonymous> (/zkopru/node_modules/truffle/build/webpack:/packages/compile-common/dist/src/profiler/getImports.js:23:1)
    at Generator.next (<anonymous>)
    at /zkopru/node_modules/truffle/build/webpack:/packages/compile-common/dist/src/profiler/getImports.js:8:1
    at new Promise (<anonymous>)
    at __awaiter (/zkopru/node_modules/truffle/build/webpack:/packages/compile-common/dist/src/profiler/getImports.js:4:1)
    at Object.getImports (/zkopru/node_modules/truffle/build/webpack:/packages/compile-common/dist/src/profiler/getImports.js:19:1)
    at /zkopru/node_modules/truffle/build/webpack:/packages/compile-common/dist/src/profiler/resolveAllSources.js:58:1
    at Generator.next (<anonymous>)
    at fulfilled (/zkopru/node_modules/truffle/build/webpack:/packages/compile-common/dist/src/profiler/resolveAllSources.js:5:42)
Truffle v5.1.66 (core: 5.1.66)
Node v14.14.0
error Command failed with exit code 1.

Environment

haltman-at commented 3 years ago

I'm pretty sure this is the same issue as #3799. There's already a PR merged to fix it which should go out in tomorrow's release. Still, thanks for the report!

chancehudson commented 3 years ago

Ah, thanks for the heads up! I'll reopen if the next release doesn't fix.