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
The following module produces a type warning that (as best I can tell) is not correct. Note that replacing the interpolated value #{known_locale_count} with #{inspect known_locale_count} result in no type warning. Somehow the interpolation is affecting the assumption of the type of known_locale_count - the relevant part of the warning seems to be:
defmoduleTypeCheckdo@warn_if_greater_than100@locales[:ar,:ca,:"ca-ES-valencia",:de,:doi,:en,:"en-001",:"en-AU",:"en-GB",:es,:fr,:"fr-CA",:it,:ja,:nb,:no,:pl,:th,:und]definstall_locales(config)doknown_locale_count=@locales|>Enum.count()locale_string=ifknown_locale_count>1,do: "locales named ",else: "locale named "IO.puts("Generating #{inspect(config.backend)} for #{known_locale_count} "<>locale_string<>"#{inspect(@locales,limit: 5)} with "<>"a default locale named #{:en}")ifknown_locale_count>@warn_if_greater_thandoIO.puts("Please be patient, generating functions for many locales "<>"can take some time")endendend
Type message
iex-SmixErlang/OTP28[RELEASE CANDIDATE 2][erts-16.0][source][64-bit][smp:10:10][ds:10:10:10][async-threads:1][jit]warning: comparisonwithstructsfound:known_locale_count>100giventypes:dynamic(%Date{}or%DateTime{}or%NaiveDateTime{}or%Time{}or%URI{}or%Version{}or%Version.Requirement{}oratom()orbinary()orfloat()orinteger()orlist(term()))>integer()where"known_locale_count"wasgiventhetype:# type: dynamic(%Date{}or%DateTime{}or%NaiveDateTime{}or%Time{}or%URI{}or%Version{}or%Version.Requirement{}oratom()orbinary()orfloat()orinteger()orlist(term()))# from: lib/type_check.ex:17to_string(known_locale_count)Comparisonoperators(>,<,>=,<=,min,and max)performstructuralandnotsemanticcomparison.Comparingwithastructwon't give meaningful results. Structs that can be compared typically define a compare/2 function within their modules that can be used for semantic comparison.
typing violation found at:
│
23 │ if known_locale_count > @warn_if_greater_than do
│ ~
│
└─ lib/type_check.ex:23:27: TypeCheck.install_locales/1
Expected behavior
No type error is expected since:
known_locale_count=@locales|>Enum.count()
is determined by the result of Enum.count/1.
The text was updated successfully, but these errors were encountered:
Elixir and Erlang/OTP versions
Operating system
MacOS
Current behavior
The following module produces a type warning that (as best I can tell) is not correct. Note that replacing the interpolated value
#{known_locale_count}
with#{inspect known_locale_count}
result in no type warning. Somehow the interpolation is affecting the assumption of the type ofknown_locale_count
- the relevant part of the warning seems to be:Example module
Type message
Expected behavior
No type error is expected since:
is determined by the result of
Enum.count/1
.The text was updated successfully, but these errors were encountered: