tree-sitter-graph icon indicating copy to clipboard operation
tree-sitter-graph copied to clipboard

Allow optional globals be omitted

Open bm-w opened this issue 8 months ago • 5 comments

When defining an optional global, currently the library still requires that it be set in the ExecutionConfig::globals passed to File::execute, or it fails with an ExecutionError(MissingGlobalVariable("MY_GLOBAL")). This change allows the global to be omitted:

constant MY_GLOBAL?
let globals = Variables::new(); // Empty; `MY_GLOBAL` does not need to be set
let config = ExecutionConfig::new(&functions, &globals);
let graph = file.execute(tree, source, &config, &NoCancellation)?;

bm-w avatar Jun 12 '24 02:06 bm-w