Older nightlies with leading zeros in version string crash `soljson`
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 349
- Avg merge
- 8m
- Merged PRs (30d)
- 1
Description
Originally reported in https://github.com/ethereum/solc-bin/pull/21#discussion_r746961386.
`soljson-v0.4.1-nightly.2016.9.9+commit.79867f49.js` crashes solc-js because the version it reports apparently does not conform to semver. solc-js should be able to handle that more gracefully.
This happens for `--version` and `--bin`. Probably in other cases too.
### Repro
```bash
npm install solc
curl https://binaries.soliditylang.org/bin/soljson-v0.4.1-nightly.2016.9.9+commit.79867f49.js --location --output node_modules/solc
npx solcjs --version
```
Running the above produces the following exception:
```
TypeError: Invalid Version: 0.4.1-nightly.2016.09.09+commit.79867f49.Emscripten.clang
at new SemVer (/tmp/s/node_modules/semver/semver.js:323:11)
at compare (/tmp/s/node_modules/semver/semver.js:614:10)
at Function.gt (/tmp/s/node_modules/semver/semver.js:643:10)
at setupMethods (/tmp/s/node_modules/solc/wrapper.js:20:27)
at Object. (/tmp/s/node_modules/solc/index.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure with the documented npm install, curl, and npx solcjs --version commands, then inspect wrapper.js at the setupMethods stack-trace entry point. Trace the version handling used by --version and --bin, and verify that the older nightly identifier no longer throws an Invalid Version exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, typescript
- Domain
- cli, compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100