summaryrefslogtreecommitdiff
path: root/tests/initializer-list/struct-visibility-diagnostic-1.slang
blob: ab11933aeeae570507a2f752a841854f444fec8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):

public struct Visibility
{
  internal int x;
  public int y = 0;
  // the compiler does not synthesize any ctor.
  // the compiler will try to synthesize:
  //     public __init(int y);
  // but then it will find that `x` cannot be initialized.
  // so this synthesis will fail and no ctor will be added
  // to the type.
}

void test()
{
    // CHECK: error 39999: too many arguments to call (got 2, expected 1)
    Visibility t1 = {1, 2}; // error, no matching ctor
}