![](/static/23fb711/assets/icons/icon-96x96.png)
![](https://programming.dev/pictrs/image/8140dda6-9512-4297-ac17-d303638c90a6.png)
I think you’re getting a bit confused. How do you know where x
’s type is defined and therefore where x.bar
is defined if you don’t know what type x
is? It’s literally impossible. Best you can do is global type inference but that has very big limitations and is not really feasible in a language that wasn’t designed for it.
Do you think that formatters for dynamic languages need to know the type in order to format them properly? Then why in the world would you need it to know where to jump to in a type definition!?!
Not sure if that is a serious question, but it’s because formatting doesn’t depend on the type of variables but going to the definition of a field obviously depends on the type that the field is in.
Maybe my example was not clear enough for you - I guess it’s possible you’ve never experienced working intellisense, so you don’t understand the feature I’m describing.
class A:
bar: int
class B:
bar: str
def foo(x):
return x.bar
Ctrl-click on bar
. Where does it jump to?
I skimmed it. It appears to visit the AST of the code and format that, as any formatter does. ASTs have not been type checked.
Can you give an example?
Precisely! It doesn’t know the answer so it has to guess, or make you guess.
You mean how often does the same field name come up more than once? All the time obviously! Think about common names like
id
,size
,begin
,children
, etc. etc.I’m sorry but you clearly haven’t thought this through, or you’re just happy to ignore the limitations of Ruby. I suspect the latter. Please don’t pretend they aren’t limitations though. It’s ok to say “yes this isn’t very good but I like Ruby anyway”.