Merge pull request #1829 from alixander/fix-bad-import

fix bad import syntax edge case
This commit is contained in:
Alexander Wang 2024-02-05 14:19:27 -08:00 committed by GitHub
commit defdde0e24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View file

@ -3,3 +3,5 @@
#### Improvements 🧹
#### Bugfixes ⛑️
- Fixes edge case of bad import syntax crashing using d2 as a library [1829](https://github.com/terrastruct/d2/pull/1829)

View file

@ -12,7 +12,7 @@ import (
func (c *compiler) pushImportStack(imp *d2ast.Import) (string, bool) {
impPath := imp.PathWithPre()
if impPath == "" && imp.Range.Path != "" {
if impPath == "" && imp.Range != (d2ast.Range{}) {
c.errorf(imp, "imports must specify a path to import")
return "", false
}