flintrocks / flint

The Flint Programming Language for Smart Contracts
MIT License
2 stars 0 forks source link

Change . operator associativity #111

Closed Aurel300 closed 5 years ago

Aurel300 commented 5 years ago

The . operator currently has the wrong associativity. The following code:

a.b.c

Parses as a.(b.c):

BinOp(
  a
  (dot)
  BinOp(
    b
    (dot)
    c
  )
)

The AST should instead look like (a.b).c:

BinOp(
  BinOp(
    a
    (dot)
    b
  )
  (dot)
  c
)

This seems to be the cause of compiler crashes when testing nested structs. The following should compile, but currently does not:

struct Inner {
  var x: Int
  init() {
    self.x = 3
  }
}
struct Outer {
  var inner: Inner
  init() {
    self.inner = Inner()
  }
}
contract Test {}
Test :: (any) {
  public init() {
    var s: Outer = Outer()
    s.inner.x = 5
  }
}