Add MAP import to all modules containing configs#1965
Conversation
Only by name so we keep efficiency. This fixes some module duplication issues when importing new modules.
The first one does the same thing.
dwightguth
left a comment
There was a problem hiding this comment.
Can you explain to me why this change is needed in order to fix Algorand on your PR when it works fine on master already? If you can't explain why it's needed, I really can't justify this.
|
@dwightguth this seems like a bugfix to me (or at least, the intent is one, based on my conversations with @radumereuta on Slack). He discovered (while doing other work), that if the This works if your |
The default behavior preserves import structure
|
@dwightguth ignore Algorand for now. I encounter errors like this sometimes, and I prefer to fix that if it's isolated instead of trying to work around it to push another PR. (in this case the scanner changes) @ehildenb I've removed the equals method completely. Now the default behavior checks for: This is related partially to #1838. It mitigates it a bit, but not completely. I have a bit more confidence that at least it no longer duplicates modules semantically. |
dwightguth
left a comment
There was a problem hiding this comment.
This seems an acceptable change if I view it as purely unrelated to the scanner changes, and if it can resolve some of the issues with duplicated modules later in the pipeline, so much the better. We should have a discussion about what exactly we want the behavior of K to be here, though, before we merge this. We automatically imported MAP into the main module prior because the definition doesn't work without it. Forcing the other modules to explicitly import MAP if they use map productions makes the import system more consistent, but the configuration declaration semantics inconsistent. Whereas, allowing the other modules to automatically import MAP makes the semantics of configuration declarations more consistent, but the semantics of imports less consistent. I don't have a strong opinion on which is better, but it seems there are pros and cons to both, so we should probably discuss this as a design change rather than treating it purely like a bugfix.
|
|
||
| override lazy val hashCode: Int = name.hashCode | ||
|
|
||
| override def equals(that: Any) = that match { |
There was a problem hiding this comment.
If we're going to be using the default equals for case classes, let's use the default hashCode as well.
There was a problem hiding this comment.
I thought about that. But I think this is faster and still safe.
It's only used to quickly determine if two modules are different. And in our case, that happens most of the time since a Definition has unique Module names.
|
Master behavior: This gives an error message: So I view this branch as actually a bug fix. It makes the behavior more consistent. |
|
I mean, it makes it so that an anomaly is more consistently anomalous, if that's what you mean. That's not the same thing as just being unqualifiedly more consistent. As I said, I want to see us discuss this as a group, even if it's brief because everyone has consensus. |
|
Timings: I tested EVM with and w/o hashCode: |
This simple test fails on master.
The
MAPmodule should be added to every module where a configuration is present.