Skip to content

Commit

Permalink
err with ref
Browse files Browse the repository at this point in the history
Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>
  • Loading branch information
kartikaysaxena authored and tstirrat15 committed Feb 20, 2025
1 parent 5d9efdf commit 1777150
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/composableschemadsl/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func Compile(schema InputSchema, prefix ObjectPrefixOption, opts ...Option) (*Co
globallyVisitedFiles: mapz.NewSet[string](),
locallyVisitedFiles: mapz.NewSet[string](),
sourceFolder: cfg.sourceFolder,
mapper: mapper,
}, root)
if err != nil {
return nil, err
Expand Down
4 changes: 3 additions & 1 deletion pkg/composableschemadsl/compiler/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ type importResolutionContext struct {
// find a cycle, even if we're otherwise marking globally visited nodes.
locallyVisitedFiles *mapz.Set[string]
sourceFolder string
mapper input.PositionMapper
}

// Takes a parsed schema and recursively translates import syntax and replaces
Expand Down Expand Up @@ -812,14 +813,15 @@ func translateImports(itctx importResolutionContext, root *dslNode) error {
// This is a new node provided by the translateImport
parsedImportRoot, err := importFile(filePath)
if err != nil {
return err
return toContextError("failed to read import in schema file", "", topLevelNode, itctx.mapper)
}

// We recurse on that node to resolve any further imports
err = translateImports(importResolutionContext{
sourceFolder: newSourceFolder,
locallyVisitedFiles: currentLocallyVisitedFiles,
globallyVisitedFiles: itctx.globallyVisitedFiles,
mapper: itctx.mapper,
}, parsedImportRoot)
if err != nil {
return err
Expand Down

0 comments on commit 1777150

Please sign in to comment.