Repository: hylo-lang/hylo (swift)

Issue:
Structures without elements produce error in init function
```
public type Foo {
  public init() { }
}
```
Results in
```
error: set parameter not initialized before function returns
```

Pull request description:
Fixes: https://github.com/hylo-lang/hylo/issues/997

Alternative approach to https://github.com/hylo-lang/hylo/pull/1014

Patch:
diff --git a/Sources/IR/Emitter.swift b/Sources/IR/Emitter.swift
index bf746b5eb..613689402 100644
--- a/Sources/IR/Emitter.swift
+++ b/Sources/IR/Emitter.swift
@@ -316,6 +316,14 @@ struct Emitter {
     insertionPoint = .end(of: entry)
     let bodyFrame = Frame(locals: locals)
     let returnSite = pushing(bodyFrame, { $0.lowerStatements($0.ast[d].body!, expecting: .void) })
+
+    let receiverLayout = AbstractTypeLayout(of: program[d].receiver.type, definedIn: program)
+
+    // If the object is empty, simply mark it initialized.
+    if receiverLayout.properties.isEmpty {
+      let receiver = entry.parameter(0)
+      insert(module.makeMarkState(receiver, initialized: true, at: ast[d].site))
+    }
     insert(module.makeReturn(at: returnSite))
   }
 


Test patch:
diff --git a/Tests/HyloTests/TestCases/Lowering/EmptyStruct.hylo b/Tests/HyloTests/TestCases/Lowering/EmptyStruct.hylo
new file mode 100644
index 000000000..73d82fb9c
--- /dev/null
+++ b/Tests/HyloTests/TestCases/Lowering/EmptyStruct.hylo
@@ -0,0 +1,5 @@
+//- lowerToFinishedIR expecting: success
+
+public type Foo {
+  public init() { }
+}