Fix jsonnet-lint erorr when linting importing files and imported files at the same time: #544#548
Fix jsonnet-lint erorr when linting importing files and imported files at the same time: #544#548thombashi wants to merge 2 commits intogoogle:masterfrom
Conversation
…s at the same time: google#544
|
Thanks for sending this. I think your diagnosis is correct, but the solution causes other problems. I think that now if you use EvaluateAnonymousSnippet multiple times, you'll actually get the first one evaluated every time. The very idea behind the So to fix this I would go a slightly different route. (a) Figure out why returning different root nodes causes issues in the first place. Intuitively it should be slower, but still work. (b) Change the API of the linter to take the filenames and use |
|
Sorry this sat for so long (although at least this one had an initial review when it was first sent). The crash here has been fixed, perhaps inadvertently, by #725, which isolates more of the processing of each individual file in a multi-file lint invocation. |
This PR aims to fix #544.
I also encounter #544 (the same case with #544 (comment))
Please let me know if my understanding is wrong.
The problem seems to be caused by XxxtoAST (
ImportASTandSnippetToAST) functions return different Node instances, even with the same arguments.Specifically, about using the
ast.Nodecache.ImportASTfunction (callSnippetToASTfunction internally) usesast.Nodecache, while a direct call ofSnippetToASTfunction does not use the cache.So, the return values are different (e.g.
LocationRange.File).This will results missing key at
getExprPlaceholder.To fix this problem, I made changes to
SnippetToASTto use the same cache withImportAST.After applied the PR: