cannot call Set#intersection for set with Proxy
Vue version
fd5c001
Link to minimal reproduction
https://play.vuejs.org/#eNqlVE1v2zAM/SuELrUBI8HWngInWTf00AHbina3aQfHYVK3smRIcpIi838fJdUf84IMWE8WyafHxw/5yK6rarKrkc1YanJdVBYM2roCkcntnDNrOFtwWZSV0haOoHGTgFX32R4a2GhVwgXdvuCSy1xJY6F8eUALcweMJO6BrOjHuwTeJ3D5M45bWCaVfUR9AuuACVwNsBpNLWwHTemUyrpcoV7AL6jlGjeFxPUi6o50tb28RXsrLWqDuS2UJIrIy//idM5gpZTATL7WdN2p6iIxzBdw5BJ6GZNdJmokpi6fC4d0QuWZ8NwU7xPBMhiRb08giGEWuhXMEUcvpSUaeFq2vos95djneE/L77VOikGLolF+ambDZToN60HLQIbFshKZRbIGzDM4ug1pp7VcAmd9j1hDNA6frmpraRQfclHkz7RkoxlFm0wYTMB/Ytq/O60OL6F1cQLB6suM02kg9GL+SW51PeQejOXt3K/CXYq/dY9H9l+6W+o/ZZ+jTqeDYbGEXjRt2abYTp6MkvTs/W5zlquyKgTqb5XLRq+ehukiLpYJofafvc+raP35I+bPJ/xP5uB8nN3RMqDeIWddzGaaKgvhm4eveKBzFyzVuhaEPhO8R6NE7TQG2EdaMJI9wHm1t/6HVcjtd3NzsChNW5QT6pCNx3NGf69PZ0rv5V5Orvw9eg2s+Q0+UdCt
Steps to reproduce
- Create a set with Proxy, such as
ref(new Set([...])) - Call
Set#intersection
What is expected?
It shouldn't throw an error
What is actually happening?
It throws error: "Set operation called on non-Set object"
System Info
Vue: fd5c001
TypeScript: 5.5.3
Any additional comments?
There is a workaround: toRaw(mySet.value).intersection does not throw error.
Looks like this issue also applies to some other Set methods:
- difference
- isSubsetOf
- isSupersetOf
- isDisjointFrom
- symmetricDifference
- union
Your version linking to 3.4.32 release note made me think it's a regression, but it seems the behavior has always been like this since Vue 3?
I can reproduce this issue in Vue 3.2, 3.3 too.
Somehow I couldn't run the code in that playground in Vue 3.0 and 3.1 (even though @vue/compiler-sfc was installed), so I haven't checked that.
我想问一句,set的原生方法intersection不支持带proxy的set,这不是很正常吗?为啥要提issue,而且还有人给解决了?我理解,框架不是自有一套逻辑,为啥要这样兼容各种看似跟框架设计不一样的问题呢,谁能解答一下
On vue v3.5.22, similar error is occured but message is
Method Set.prototype.intersection called on incompatible receiver #<Set>
It can be reproduced with @sevenc-nanashi 's playground + vue v3.5.22.
The workaround is the same. Use toRaw.