Fix checks for "using for ... global" for libraries.

This commit is contained in:
chriseth
2022-05-02 12:40:56 +02:00
parent 25923c1f08
commit 505fa7763f
11 changed files with 122 additions and 24 deletions
@@ -4,4 +4,3 @@ contract C {
function f(uint) pure{}
// ----
// SyntaxError 3367: (17-43): "global" can only be used at file level.
// TypeError 8841: (17-43): Can only use "global" with user-defined types.
@@ -0,0 +1,9 @@
using L for uint global;
using L for uint[] global;
using L for function() returns (uint) global;
library L {
}
// ----
// TypeError 8841: (0-24): Can only use "global" with user-defined types.
// TypeError 8841: (25-51): Can only use "global" with user-defined types.
// TypeError 8841: (52-97): Can only use "global" with user-defined types.
@@ -0,0 +1,6 @@
using L for L.S global;
library L {
struct S { uint x; }
}
// ----
// TypeError 4117: (0-23): Can only use "global" with types defined in the same source unit at file level.
@@ -0,0 +1,6 @@
interface I {}
using L for I global;
library L {
}
// ----
// TypeError 8841: (15-36): Can only use "global" with user-defined types.
@@ -0,0 +1,8 @@
==== Source: A ====
struct S { uint x; }
==== Source: B ====
library L {}
using L for S global;
import {S} from "A";
// ----
// TypeError 4117: (B:13-34): Can only use "global" with types defined in the same source unit at file level.
@@ -0,0 +1,5 @@
using L for * global;
library L {}
// ----
// SyntaxError 8118: (0-21): The type has to be specified explicitly at file level (cannot use '*').
// SyntaxError 2854: (0-21): Can only globally bind functions to specific types.
@@ -0,0 +1,5 @@
using {f} for * global;
function f(uint) pure{}
// ----
// SyntaxError 8118: (0-23): The type has to be specified explicitly at file level (cannot use '*').
// SyntaxError 2854: (0-23): Can only globally bind functions to specific types.