Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
Why is Swift compiler complaining about circular reference when I comment out seemingly unrelated code?

Creating a brand new macOS Command Line Tool project in Xcode Version 13.3 (13E113), and replacing the contents of main.swift with the following code:

import Foundation

enum StructA {
    // case case1(value: StructB)
    case case2(expr: StructB)
}

indirect enum StructB {
    case case3
    case case4(expr: StructB)
}

Results in the following compile-time error:

<unknown>:0: error: circular reference
/Users/alextj/projects/TestProject/main.swift:8:15: note: through reference here
indirect enum StructB {
              ^
<unknown>:0: note: through reference here

However, if you uncomment the case1 line, then the circular reference error goes away!

So the following code compiles without errors:

import Foundation

enum StructA {
    case case1(value: StructB)
    case case2(expr: StructB)
}

indirect enum StructB {
    case case3
    case case4(expr: StructB)
}

Why?

Why does commenting out case1 cause a circular reference?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!