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

Error: Arrays and dictionaries cannot be defined as local variables yet #466

Open
wmanshu opened this issue Aug 22, 2019 · 2 comments
Open

Comments

@wmanshu
Copy link

wmanshu commented Aug 22, 2019

contract Reputation {
  ...
  var ratings: [Address : [Feedback]] = [:]
}
struct Feedback {
  var isPositive: Bool
  var reviewer: Address
  var optionalMessage: String
}

  public func getNumberOfPositiveReviews(recipient: Address) -> Int
  {
    let feedback: [Feedback] = ratings[recipient]
    var count: Int = 0

     for var f: Feedback in feedback {
       if f.isPositive {
         count += 1
       }
     }
    return count
  }

error (--skip-verifier case):

Arrays and dictionaries cannot be defined as local variables yet

at let feedback: [Feedback] = ratings[recipient]

file: reputation.flint

@wmanshu
Copy link
Author

wmanshu commented Aug 22, 2019

simpler example, same error:

struct S {
  var x: Int
  var y: Int

  init(x: Int, y: Int) {
    self.x = x
    self.y = y
  }
}

contract A  {
  var arr2: [Address: [S]] = [:]
}

A :: caller <- (any) {
  public init()  {}

  func getarr2()
  pre (dictContains(arr2, caller) == true)
  {
    var ss: [S] = arr2[caller]
  }

}


happens at var ss: [S] = arr2[caller]

@wmanshu
Copy link
Author

wmanshu commented Aug 23, 2019

#459 related

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