Skip to content

Commit 1a1195d

Browse files
committed
Make sure link errors propagate
1 parent 6b72d05 commit 1a1195d

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

snap-core/src/main/java/org/snapscript/core/link/PackageBundleLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ private Package load(Path path) throws Exception {
5959
FuturePackage result = new FuturePackage(task, path);
6060

6161
if(registry.putIfAbsent(path, result) == null) {
62-
task.run();
62+
task.run(); // call a validate method here
6363
}
64-
return registry.get(path);
64+
return registry.get(path); // return the future package
6565
}
6666
}
6767
return module;

snap-core/src/main/java/org/snapscript/core/link/StatementDefinition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public Statement compile(Scope scope, Path from) throws Exception {
4040

4141
if(reference.compareAndSet(null, result)) {
4242
task.run();
43-
return statement;
43+
return result;
4444
}
4545
}
46-
return reference.get();
46+
return reference.get(); // return future package
4747
}
4848
return empty;
4949
}

snap-core/src/main/java/org/snapscript/core/link/StatementPackage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public PackageDefinition define(Scope scope) throws Exception {
3838

3939
if(reference.compareAndSet(null, result)) {
4040
task.run();
41-
return definition;
41+
return result; // must be future package for errors
4242
}
4343
}
44-
return reference.get();
44+
return reference.get(); // return future package
4545
}
4646

4747
private class Executable implements Callable<PackageDefinition> {

snap-tree/src/main/java/org/snapscript/tree/define/ClassBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public Result compile(Scope outer) throws Exception {
3939
Scope scope = type.getScope();
4040

4141
annotations.apply(scope, type);
42-
hierarchy.update(scope, type);
4342
builder.declare(scope, type);
43+
hierarchy.update(scope, type); // this may throw exception if missing type
4444

4545
return ResultType.getNormal(type);
4646
}

snap-tree/src/main/java/org/snapscript/tree/define/EnumBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public Result compile(Scope outer) throws Exception {
4040
Type type = module.getType(alias);
4141
Scope scope = type.getScope();
4242

43-
hierarchy.update(scope, type);
4443
builder.declare(scope, type, values);
44+
hierarchy.update(scope, type); // this may throw exception if missing type
4545

4646
return ResultType.getNormal(type);
4747
}

0 commit comments

Comments
 (0)