Author brandtbucher
Recipients brandtbucher, jack__d, xtreak
Date 2021-07-28.17:46:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Evaluating every key in every mapping pattern and checking them for duplicates every time a match block is entered would be prohibitively expensive, for negligible gain. The length check exists to avoid this step, replacing it with a much cheaper O(1) trapdoor.

Imagine the overhead of validating this match statement, for example:

> Consider if some other code is mutating the value of `A.a`. This could create some very strange and flaky bugs where the state of `A.a` can change and make the pattern invalid, but nonetheless not cause an exception until much later, or not at all.

That's okay with me; it's not the VM's job to check the runtime validity of branches that aren't taken.

> Another option if this problem is isolated to mapping patterns, we could introduce a new op-code: BUILD_MATCH_MAP, which is essentially a wrapper around BUILD_MAP that disallows duplicate key values.

I'm not sure what you mean by this. We don't call BUILD_MAP when evaluating mapping patterns... in fact, we don't build any dictionaries at all (except for collecting remaining items using **rest).

Unless others disagree, I'm probably going to close this as "not a bug".
Date User Action Args
2021-07-28 17:46:45brandtbuchersetrecipients: + brandtbucher, xtreak, jack__d
2021-07-28 17:46:45brandtbuchersetmessageid: <>
2021-07-28 17:46:45brandtbucherlinkissue44658 messages
2021-07-28 17:46:45brandtbuchercreate