Skip to content

Commit cdcdeb9

Browse files
committed
[IRGen] Fix return values for typed throws with empty error
When the error is an empty type, the return value for the error case needs to be an `undef` value of the result type, or `void`, if the result type is `void`
1 parent 5785d45 commit cdcdeb9

File tree

2 files changed

+47
-1868
lines changed

2 files changed

+47
-1868
lines changed

lib/IRGen/GenThunk.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,12 @@ void IRGenThunk::emit() {
419419
/*forAsync*/ false, nativeAgg);
420420
IGF.emitScalarReturn(IGF.CurFn->getReturnType(), nativeAgg);
421421
} else {
422-
IGF.emitScalarReturn(IGF.CurFn->getReturnType(), *error);
422+
if (IGF.CurFn->getReturnType()->isVoidTy()) {
423+
IGF.Builder.CreateRetVoid();
424+
} else {
425+
IGF.Builder.CreateRet(
426+
llvm::UndefValue::get(IGF.CurFn->getReturnType()));
427+
}
423428
}
424429
}
425430
IGF.Builder.emitBlock(successBB);

0 commit comments

Comments
 (0)