aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java b/src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java
index a5996ef7..781468e0 100644
--- a/src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java
+++ b/src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java
@@ -53,11 +53,9 @@ public class TypeChecker {
private static TypeCheckerResult<Variable> runtimeLookup(String name, Source source, TypeCheckerContext context) {
return context.runtimeLookup(name, source).map(variable -> {
- if (variable.isEmpty()) {
- throw new UnknownVariableError(name, source);
- }
-
- variable.get().type()
+ variable
+ .orElseThrow(() -> new UnknownVariableError(name, source))
+ .type()
.orElseThrow(() -> new ReferenceBeforeDefinitionError(name, source));
return variable.get();