diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmExceptionBuilder.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmExceptionBuilder.java index bb69ccaf6..68ac2fc15 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmExceptionBuilder.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmExceptionBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -345,6 +345,10 @@ public VmExceptionBuilder withInsertedStackFrames( return this; } + public VmExceptionBuilder stackOverflowError() { + return evalError("stackOverflow"); + } + public VmException build() { if (message == null) { throw new IllegalStateException("No message set."); diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmTyped.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmTyped.java index da768bb6c..c3160254f 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmTyped.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmTyped.java @@ -204,7 +204,7 @@ public int hashCode() { for (var key : clazz.getAllRegularPropertyNames()) { var value = getCachedValue(key); - assert value != null; + if (value == null) throw new VmExceptionBuilder().stackOverflowError().build(); result = 31 * result + value.hashCode(); }