Merge pull request #9614 from ethereum/yul-hex

Update tests/documentation to show that hex literals are not supported in Yul
This commit is contained in:
Daniel Kirchner 2020-08-13 03:11:45 +02:00 committed by GitHub
commit 5d670aaa18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 61 additions and 4 deletions

View File

@ -476,9 +476,8 @@ which are explained in their own chapter.
TypeName = Identifier
TypedIdentifierList = Identifier ( ':' TypeName )? ( ',' Identifier ( ':' TypeName )? )*
Literal =
(NumberLiteral | StringLiteral | HexLiteral | TrueLiteral | FalseLiteral) ( ':' TypeName )?
(NumberLiteral | StringLiteral | TrueLiteral | FalseLiteral) ( ':' TypeName )?
NumberLiteral = HexNumber | DecimalNumber
HexLiteral = 'hex' ('"' ([0-9a-fA-F]{2})* '"' | '\'' ([0-9a-fA-F]{2})* '\'')
StringLiteral = '"' ([^"\r\n\\] | '\\' .)* '"'
TrueLiteral = 'true'
FalseLiteral = 'false'
@ -688,8 +687,6 @@ We will use a destructuring notation for the AST nodes.
L'[$parami] = vi and L'[$reti] = 0 for all i.
Let G'', L'', mode = E(Gn, L', block)
G'', Ln, L''[$ret1], ..., L''[$retm]
E(G, L, l: HexLiteral) = G, L, hexString(l),
where hexString decodes l from hex and left-aligns it into 32 bytes
E(G, L, l: StringLiteral) = G, L, utf8EncodeLeftAligned(l),
where utf8EncodeLeftAligned performs a utf8 encoding of l
and aligns it left into 32 bytes

View File

@ -0,0 +1,9 @@
contract C {
function f() public pure {
assembly {
let x := hex"0011"
}
}
}
// ----
// ParserError 1856: (72-81): Literal or identifier expected.

View File

@ -0,0 +1,9 @@
contract C {
function f() public pure {
assembly {
pop(hex"2233")
}
}
}
// ----
// ParserError 1856: (67-76): Literal or identifier expected.

View File

@ -0,0 +1,11 @@
contract C {
function f() public pure {
assembly {
switch codesize()
case hex"00" {}
case hex"1122" {}
}
}
}
// ----
// ParserError 1856: (92-99): Literal or identifier expected.

View File

@ -0,0 +1,9 @@
contract C {
function f() public pure {
assembly {
switch codesize()
case "1" {}
case "2" {}
}
}
}

View File

@ -0,0 +1,5 @@
{
let x := hex"0011"
}
// ----
// ParserError 1856: (15-24): Literal or identifier expected.

View File

@ -0,0 +1,5 @@
{
pop(hex"2233")
}
// ----
// ParserError 1856: (10-19): Literal or identifier expected.

View File

@ -0,0 +1,7 @@
{
switch codesize()
case hex"00" {}
case hex"1122" {}
}
// ----
// ParserError 1856: (33-40): Literal or identifier expected.

View File

@ -0,0 +1,5 @@
{
switch codesize()
case "1" {}
case "2" {}
}