mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Analyze inline assembly variable declarations for invalid or shadowing names.
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
assembly {
|
||||
let x_offset := 1
|
||||
let x_slot := 1
|
||||
let _offset := 1
|
||||
let _slot := 1
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (79-87): In variable declarations _slot and _offset can not be used as a suffix.
|
||||
// DeclarationError: (109-115): In variable declarations _slot and _offset can not be used as a suffix.
|
||||
// DeclarationError: (137-144): In variable declarations _slot and _offset can not be used as a suffix.
|
||||
// DeclarationError: (166-171): In variable declarations _slot and _offset can not be used as a suffix.
|
||||
@@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f(uint a) public pure {
|
||||
assembly {
|
||||
let a := 1
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (85-86): This declaration shadows a declaration outside the inline assembly block.
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
uint constant a;
|
||||
function f() public pure {
|
||||
assembly {
|
||||
let a := 1
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (100-101): This declaration shadows a declaration outside the inline assembly block.
|
||||
@@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
assembly {
|
||||
let C := 1
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (79-80): This declaration shadows a declaration outside the inline assembly block.
|
||||
@@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
assembly {
|
||||
let f := 1
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (79-80): This declaration shadows a declaration outside the inline assembly block.
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint a;
|
||||
assembly {
|
||||
let a := 1
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (95-96): This declaration shadows a declaration outside the inline assembly block.
|
||||
@@ -0,0 +1,18 @@
|
||||
==== Source: a ====
|
||||
contract A
|
||||
{
|
||||
uint constant a = 42;
|
||||
}
|
||||
==== Source: b ====
|
||||
import {A as b} from "a";
|
||||
contract B {
|
||||
function f() public pure {
|
||||
assembly {
|
||||
let b := 3
|
||||
let b.a := 4
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (b:105-106): This declaration shadows a declaration outside the inline assembly block.
|
||||
// DeclarationError: (b:128-131): The prefix of this declaration conflicts with a declaration outside the inline assembly block.
|
||||
@@ -0,0 +1,15 @@
|
||||
==== Source: a ====
|
||||
contract A
|
||||
{
|
||||
uint constant a = 42;
|
||||
}
|
||||
==== Source: b ====
|
||||
import {A as b} from "a";
|
||||
contract B {
|
||||
function f() public pure {
|
||||
assembly {
|
||||
let A := 1
|
||||
let A.b := 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
contract D {
|
||||
uint constant a;
|
||||
}
|
||||
contract C {
|
||||
function f() public pure {
|
||||
assembly {
|
||||
let D.a := 1
|
||||
let D.b := 1 // shadowing the prefix only is also an error
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (115-118): The prefix of this declaration conflicts with a declaration outside the inline assembly block.
|
||||
// DeclarationError: (140-143): The prefix of this declaration conflicts with a declaration outside the inline assembly block.
|
||||
Reference in New Issue
Block a user