From 8cf7618dfbe5ca81991439828eb5dd638712d1da Mon Sep 17 00:00:00 2001 From: svtk Date: Tue, 22 Nov 2011 15:09:59 +0400 Subject: [PATCH] KT-41 Make functions with errors in returning statement return ERROR type and not Nothing --- .../types/expressions/ExpressionTypingServices.java | 3 +++ .../checkerWithErrorTypes/quick/regressions/kt41.jet | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt41.jet diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java index cfbe176d509..108796a2d2b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java @@ -188,6 +188,9 @@ public class ExpressionTypingServices { trace.record(STATEMENT, returnedExpression, false); if (cachedType != null) { typeMap.put(returnedExpression, cachedType); + } + else { + typeMap.put(returnedExpression, ErrorUtils.createErrorType("Error function type")); } } return typeMap; diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt41.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt41.jet new file mode 100644 index 00000000000..84ec9616fae --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt41.jet @@ -0,0 +1,11 @@ +// KT-41 Make functions with errors in returning statement return ERROR type and not Nothing + +namespace kt41 + +fun aaa() = + 6 foo 1 + +fun bbb() { + aaa() + 1 // Stupid error: unreachable code +} \ No newline at end of file