-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #239 from DJRHails/address_literal
Support address literals
- Loading branch information
Showing
8 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// RUN: %flintc %s --dump-ast | %FileCheck %s --prefix CHECK-AST | ||
|
||
// CHECK-AST: ContractDeclaration | ||
// CHECK-AST: identifier "Foo" | ||
contract Foo {} | ||
|
||
Foo :: (any) { | ||
// CHECK-AST: InitializerDeclaration | ||
// CHECK-AST: public | ||
public init() {} | ||
|
||
func foo() -> Int { | ||
|
||
// CHECK-AST: BinaryExpression | ||
// CHECK-AST: VariableDeclaration | ||
// CHECK-AST: var | ||
// CHECK-AST: identifier "a" | ||
// CHECK-AST: built-in type Int | ||
// CHECK-AST: = | ||
// CHECK-AST: literal 2 | ||
var a: Int = 2 | ||
return a | ||
} | ||
|
||
// CHECK-AST: BinaryExpression | ||
// CHECK-AST: VariableDeclaration | ||
// CHECK-AST: let | ||
// CHECK-AST: identifier "a" | ||
// CHECK-AST: built-in type String | ||
// CHECK-AST: = | ||
// CHECK-AST: literal "hello" | ||
func bar() -> String { | ||
let a: String = "hello" | ||
return a | ||
} | ||
|
||
// CHECK-AST: BinaryExpression | ||
// CHECK-AST: VariableDeclaration | ||
// CHECK-AST: let | ||
// CHECK-AST: identifier "a" | ||
// CHECK-AST: built-in type Address | ||
// CHECK-AST: = | ||
// CHECK-AST: literal 0x0000000000000000000000000000000000000000 | ||
func zoo() -> Address { | ||
let a: Address = 0x0000000000000000000000000000000000000000 | ||
return a | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// RUN: %flintc %s --verify | ||
|
||
contract Literals {} | ||
|
||
Literals :: (any) { | ||
public init() {} | ||
|
||
func foo() -> Address { | ||
return 0xF668Cb74A4E9901972057cf4BEAC00b8826Fa99D | ||
} | ||
|
||
func bar() { | ||
// 41 characters | ||
let a: Address = 0x668Cb74A4E9901972057cf4BEAC00b8826Fa99D // expected-error {{Address literal should be 42 characters long}} | ||
} | ||
} |