Skip to content

Commit

Permalink
use unique paths for unresolved imports in bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarTawfik committed Aug 10, 2024
1 parent 34e8c4b commit 1354383
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions crates/metaslang/bindings/src/builder/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,18 @@ mod resolver {
let path_to_resolve = parameters.param()?.into_string()?;
parameters.finish()?;

if let Some(resolved_path) = self
let resolved_path = self
.path_resolver
.as_ref()
.resolve_path(&context_path, &path_to_resolve)
{
Ok(resolved_path.into())
} else {
Ok("__SLANG_UNRESOLVED_IMPORT_PATH__".into())
}
.unwrap_or_else(|| {
// In case we cannot resolve the path, we return a special value that is unique
// per context/path pait. This way, we can still run incrementally and resolve
// other symbols in the file:
format!("__SLANG_UNRESOLVED_PATH__{context_path}__{path_to_resolve}__")
});

Ok(resolved_path.into())
}
}
}

0 comments on commit 1354383

Please sign in to comment.