Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solidity error: Expected identifier, got 'LParen'

Tags:

solidity

I'm getting the error:

Expected identifier, got 'LParen'

Problem is, this code is from the Solidity docs! I have tried many thing for this error but to no avail. The link where I got the code is: https://solidity.readthedocs.io/en/latest/solidity-by-example.html

I have an image attached with the error:

enter image description here

Can someone explain to me what I'm doing wrong? I have the right version, as per below:

kalyan@kalyan:/usr/bin$ truffle version

Truffle v4.1.13 (core: 4.1.13)

Solidity v0.4.24 (solc-js)

This is running on Ubuntu 18.04. Is there something else I should be doing?

EDIT

The code before constructor is:

/// Modifiers are a convenient way to validate inputs to
/// functions. `onlyBefore` is applied to `bid` below:
/// The new function body is the modifier's body where
/// `_` is replaced by the old function body.
modifier onlyBefore(uint _time) { require(now < _time); _; }
modifier onlyAfter(uint _time) { require(now > _time); _; }
like image 805
KVISH Avatar asked Aug 03 '18 01:08

KVISH


1 Answers

I have faced this problem with the constructor in solidity too this can be solved really easily

if you are running your code in VSCODE than you may have installed a extension Solidity Extended

then you have then UNININSTALL it and reload your vscode editor

if you may have uinstalled and not reloaded your vs code than you will face same problem

> also set the pragma solidity version to pragma solidity >=0.4.21 < 0.7.0;

this worked for me

like image 70
Samarth Gugnani Avatar answered Oct 02 '22 07:10

Samarth Gugnani