Failed to use source
built-in methods after calling method that uses source
#1833
-
Describe the bug To Reproduce
generates error
But this is valid
Expected behavior Version details
Install method Common issues |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
That's definitely another type inference issue here. Let me try to explain. Since
Now, it can happen that those methods can be "lost", for instance by adding type annotation:
You will notice that, in the first case, the source However, the method is still available internally so it is technically still possible to get the source's id, which is why (for now), we are keeping the
So, the idea is to use this operator when you are dealing with sources with no methods. However, this creates an annoying situation in case of type inference. Indeed, if you look at the function:
At line On the contrary, with:
At line Another way to write this function that works with both lines would be:
This will work even if you switch the lines around. I'll leave this open to see if @smimram has some ideas about how we could make this better. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
The value discrepancy was just fixed with: e9adaf1 😅 |
Beta Was this translation helpful? Give feedback.
-
Another solution consists in explicitely stating that
|
Beta Was this translation helpful? Give feedback.
-
Thanks @smimram. I'm moving this to a discussion since it seems that we won't be making any change based on it for now. |
Beta Was this translation helpful? Give feedback.
That's definitely another type inference issue here. Let me try to explain.
Since
2.0.0
, sources have methods, so here's a typical type for a source: