Open tothambrus11 opened 1 month ago
It is intended behavior. The purpose of the shared storage is to avoid duplicating source contents while deserializing an AST loaded from disk.
Clearly the name of the file should be unique and your code is not upholding this requirement. There's no reason to give explicit names to synthetic files, though. If you look at the constructor you'll see that the default argument is a random UUID.
@tothambrus11 unless you have some objection we haven't considere, please close the issue. Thanks.
When creating two SourceFile objects with the same file name, the second one does not get an independent storage from the first one. This was confusing because the next time we initialize a source file, it might have a completely different content at the same file name / url as the old one.
I encountered an issue while writing tests for something that involved creating source files with specific names, and I reduced the problem to the following:
The problem persists even if we are working within different test cases, which is particularly spooky and breaks value semantics.
What were the design decisions behind creating a shared storage of source files? Is this a bug or intended behaviour? Can we maybe make this issue less likely to happen, e.g. only making a shared storage when the contents of the two source files equal?