You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@soutaro steep does not support syntax to switch a variable's type mid-code. A similar but perhaps clearer example of what happens is:
# given type a: Array[Number | :stop]a=[1,2,:stop]a.delete(:stop)# and given def func: (Array[Number]) -> voidfunc(a)
steep will signal a type error on that last call, given that a is still an "array of numbers of stop" at that point, despite the operation above. adding an annotation beforehand like @type var a: Array[Number] won't help, as steep will apply that signature to a.delete(:stop), which will error from then on, despite it being placed before the annotation.
The scope of type annotations is not very clear and might be confusing... Generally, it's based on the scope of local variables in Ruby. a is the same variable through the lines, so the @type annotation applies to all of the occurrence of a.
For this specific example, assigning to a itself with type assertion works.
a=[1,2,:stop]a.delete(:stop)a=a#: Array[Integer]# a is Array[Integer] here
this type of extension of type definitions isn't being done by steep on type analysis via
steep check
.The text was updated successfully, but these errors were encountered: