Modules that cannot be loaded for one reason or another will now include the offending import as part of the stack trace, with a clear error message.
Before:
–– Pkl Error ––
None (cause has no message)
x | res = analyze.importGraph(Set(reflect.Module(cannotFindModule).uri))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
After:
–– Pkl Error ––
Cannot find module `bogusModule.pkl`.
x | import "bogusModule.pkl"
^^^^^^^^^^^^^^^^^
at pkl.analyze#importGraph (file:///$snippetsDir/input-helper/analyze/cannotFindModule.pkl)
x | res = analyze.importGraph(Set(reflect.Module(cannotFindModule).uri))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/948
Author: @bioball
Created: 2/12/2025
Status: ✅ Merged
Merged: 2/13/2025
Merged by: @bioball
Base:
main← Head:improve-analyze-import-errors📝 Commits (3)
5db648fImprove handling of errors when analysis failsaa145bcAddress review feedback7738181Run spotless apply📊 Changes
9 files changed (+127 additions, -57 deletions)
View changed files
📝
pkl-core/src/main/java/org/pkl/core/Analyzer.java(+1 -3)📝
pkl-core/src/main/java/org/pkl/core/runtime/VmImportAnalyzer.java(+84 -47)📝
pkl-core/src/main/java/org/pkl/core/stdlib/analyze/AnalyzeNodes.java(+2 -7)➕
pkl-core/src/test/files/LanguageSnippetTests/input-helper/analyze/cannotFindModule.pkl(+1 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input-helper/analyze/invalidGlob.pkl(+1 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/errors/analyzeImportsCannotFindModule.pkl(+5 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/errors/analyzeImportsInvalidGlob.pkl(+5 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/errors/analyzeImportsCannotFindModule.err(+14 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/errors/analyzeImportsInvalidGlob.err(+14 -0)📄 Description
Modules that cannot be loaded for one reason or another will now include the offending import as part of the stack trace, with a clear error message.
Before:
After:
Closes https://github.com/apple/pkl/pull/949
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.