josefs / Gradualizer

A Gradual type system for Erlang
MIT License
612 stars 35 forks source link

Crash in typechecker:do_type_check_expr_in/3: bad_key in map_get/2 #545

Open RobinMorisset opened 1 year ago

RobinMorisset commented 1 year ago

Running gradualizer on the following Erlang code:

f() ->
    (abs(_V0 = erlang:abs(erlang:abs(1.0))) =:= ok) orelse is_map_key(_V0, ok).

results in the following crash:

escript: exception error: bad key: '_V0'
  in function  map_get/2
     called as map_get('_V0',#{})
     *** argument 1: not present in map
  in call from typechecker:do_type_check_expr_in/3 (src/typechecker.erl, line 2526)
  in call from typechecker:type_check_expr_in/3 (src/typechecker.erl, line 2514)
  in call from typechecker:'-type_check_call_ty/4-lc$^0/1-0-'/2 (src/typechecker.erl, line 2302)
  in call from typechecker:type_check_call_ty/4 (src/typechecker.erl, line 2303)
  in call from typechecker:do_type_check_expr/2 (src/typechecker.erl, line 1843)
  in call from typechecker:type_check_expr/2 (src/typechecker.erl, line 1714)
  in call from typechecker:type_check_logic_op/4 (src/typechecker.erl, line 2204)