Files
swift-mirror/test/NameLookup/library.swift
Henrik G. Olsson cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00

46 lines
1.2 KiB
Swift

// RUN: %target-swift-frontend -typecheck %s -I %S/Inputs -enable-source-import -parse-as-library -verify -verify-ignore-unrelated
// Name lookup is global in a library.
var x : x_ty = 4
typealias x_ty = Int
// Name lookup is global in a library.
// This case requires doing semantic analysis (conversion checking) after
// parsing.
var y : y_ty = 4
typealias y_ty = (Int)
// Verify that never-defined types are caught.
var z : z_ty = 42 // expected-error {{cannot find type 'z_ty' in scope}}
// Make sure we type-check all declarations before any initializers
var a : Int = b
var b : Int = 1
var c = 1
var d = 2
var e = 3
// Name lookup with imports.
import imported_module
func over1(_ x: UInt64) {} // expected-note{{found this candidate}}
func over2(_ x: UInt32) {}
func over3(_ x: UInt32) {}
typealias over4 = UInt32
func testover() {
// FIXME: Very weird diagnostic here.
over1(0) // expected-error{{ambiguous use of 'over1'}}
over2(0)
over3(0) // FIXME: Should we produce an ambiguity error here?
var x : over4 = 10
}
// Referring to name within a module.
var d2 : Swift.Int = 5
var y2 : library.y_ty = 5
func increment_y2() {
y2 = library.y2 + 1
}