fix bad import syntax edge case

This commit is contained in:
Alexander Wang 2024-02-05 14:10:16 -08:00
parent 02143580b6
commit 6272d3e8b1
No known key found for this signature in database
GPG key ID: 6A82C36A56162F42
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
}