Open Baltoli opened 2 months ago
I'm not sure this is the solution I would recommend. The problem is that even if you restrict sort names, you are still stuck with collisions in the casing of other symbols, and that's a potentially very restrictive thing to disallow completely. It's probably better to find a way to pick the filenames such that they are unique modulo case insensitivity.
One thing to note is that the llvm backend emits a table mapping symbol names to filenames, because we already have had problems in the past with filenames longer than the max filename length on Linux. So you probably just need to detect in the Scala code when files might collide and give them new names
Could we suffix each file with a hash of the original (case sensitive) sort name? Just the first 6 characters of the hash should be enough I guess.
Could we suffix each file with a hash of the original (case sensitive) sort name? Just the first 6 characters of the hash should be enough I guess.
Yeah I didn't think this through in sufficient detail last week when recording the issue - I think something like this is the right solution.
Consider the following definition:
We can see by inspection that there is no term
X
for whichisFoo(X)
andisFOO(X)
are both true. However, on macOS, we can observe the following executions:That is,
isFoo(Foo) => false
, andisFOO(Foo) => true
! Both of these rewrites are incorrect.Some digging reveals that the reason for this is the case-insensitive filesystem on macOS; when decision trees are compiled, files
LblisFoo.yaml
andLblisFOO.yaml
are both generated. However, one of them overwrites the other because of case-insensitivity. This means that the logic for all case-insensitive-equal sorts gets collapsed into one.The solution (I think) is to disallow sorts that are equal up to casing.