question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Solidity syntax errors produce an unexpected `abort` and print two 5's to the console

See original GitHub issue

If the code sent to solc-js contains a syntax error, solc-js will throw an error with the message abort(5). It also prints two 5’s to the console. This affects the Truffle stack as all users who accidentally produce syntax errors won’t be able to diagnose the issue.

I’ve written a sample script that reproduces the error:

#!/usr/bin/env node
var solc = require("solc");

var solcStandardInput = {
  language: "Solidity",
  sources: {
    "Contract.sol": {content: "pragma solidity ^0.4.11; contract Contract { this is a syntax error }"}
  },
  settings: {
    optimizer: {
      enabled: true,
      runs: 0 // See https://github.com/ethereum/solidity/issues/2245
    },
  }
};

// This error's and prints out two 5's
solc.compileStandardWrapper(JSON.stringify(solcStandardInput));

The output you get looks like this:

screen shot 2017-06-27 at 10 33 36 am

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JohnAllencommented, Sep 7, 2017

This can happen when you declare struct members public:

struct Restaurant { bool public open; }

Also compiling files individually (if doing Truffle migrate which is how I got here) can actually throw a usable error message: solcjs file.sol --abi

0reactions
axiccommented, Jul 10, 2017

It definitely works with 0.4.13:

$ ./solcjs --version
0.4.13+commit.0fb4cb1a.Emscripten.clang
$ ./solcjs --standard-json <_113.json 
{"contracts":{},"errors":[{"component":"general","formattedMessage":"Contract.sol:1:51: ParserError: Expected identifier, got 'Is'\npragma solidity ^0.4.11; contract Contract { this is a syntax error }\n                                                  ^\n","message":"Expected identifier, got 'Is'","severity":"error","type":"ParserError"}],"sources":{}}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Truffle console doesn't work :Unexpected error: Cannot ...
I assume that Truffle has a bug that instead of reading the specific files produced by a truffle compile it tries to read...
Read more >
Remix Documentation - Read the Docs
1. Click on the script to make it the active tab in the editor. 2. Input the command remix.exeCurrent() in the console. 1.2....
Read more >
Solidity Learning: Revert(), Assert(), and Require ... - Medium
If the useSuperPowers() function is called by anyone other than owner , the function will throw returning an invalid opcode error, undoing all...
Read more >
Index Of - PHP Advanced Transfer
She will A syntax error has occurred Webbs all play, and their father has not so good an income as yours. Do The...
Read more >
javascript toastr laravel Code Example - Code Grepper
2. toast()->message('message', 'level', 'title');. 3. toast('message', 'title');. Source: github.com. Add a Grepper Answer ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found