Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External Call Issue #1 #480

Open
kunjani opened this issue Sep 27, 2019 · 0 comments
Open

External Call Issue #1 #480

kunjani opened this issue Sep 27, 2019 · 0 comments

Comments

@kunjani
Copy link

kunjani commented Sep 27, 2019

External Calling Issue

File 1:
The function Change in Bar changes the value of the global variable Value. Bar compiles and deploys correctly and the function produces the correct result.

contract Bar {
  public var Value: Int = 0
}

Bar  :: caller <- (any) {

  public init(Start: Int) {
    Value = Start
  }

  public func Change(NewValue: Int) mutates (Value) {
    Value = NewValue
  }
}

File 2:

external trait Bar {
    func Change(value: int256)
 }

contract Foo: {
  let BarAdd: Address = 0x0DCd2F752394c41875e259e00bb44fd505297caF
}

Foo  :: caller <- (any) {

  public init () {
  }

  public func changeBar(New: Int) {
    let B: Bar  = Bar (address: BarAdd)
    call! B.Change (value: New as! int256)
  }
}

The function changeBar in Foo seeks to amend the same variable by means of an external call. The flint compiler compiles this version of Foo but the Solidity compiler gives an error message:

DeclarationError: Unbalanced stack at the end of a block: 1 surplus item(s).
function Foo$changeBar$Int(_New) {
^ (Relevant source part starts here and spans across multiple lines).

This refers to a variable $temp2 which appears at the end of the Solidity function definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant