Mercury Bugs - mercury
View Issue Details
0000570mercuryBugpublic2023-12-13 13:202023-12-13 19:06
Reporterwangp 
Assigned Tozs 
PrioritynormalSeveritycrashReproducibilityalways
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000570: merge switch after switch bug
DescriptionThe compiler aborts during the deforestation, when simplify tries to merge a switch after switch:

% mmc -C --deforestation bug.m
Uncaught Mercury exception:
Software Error: map.lookup: key not found
        Key Type: parse_tree.prog_data.cons_id
        Key Value: cons(qualified(unqualified("bug"), "prepare_edit"), 0, type_ctor(qualified(unqualified("bug"), "prepare_temp"), 0))
        Value Type: uint
Stack dump follows:
   0 pred exception.throw/1-0 (erroneous) (exception.m:312)
   1 pred require.error/1-0 (erroneous) (require.m:173)
   2 pred require.report_lookup_error/3-0 (erroneous) (require.m:277)
   3 pred map.lookup/3-0 (det) (map.m:1333)
   4 pred check_hlds.simplify.simplify_goal_conj.build_maps_second_switch_cons_id/5-0 (det) (simplify_goal_conj.m:663)
   5 pred check_hlds.simplify.simplify_goal_conj.build_maps_second_switch/7-0 (det) (simplify_goal_conj.m:648)
   6 pred check_hlds.simplify.simplify_goal_conj.try_to_merge_switch_after_switch/6-0 (det) (simplify_goal_conj.m:586)
   7 6* pred check_hlds.simplify.simplify_goal_conj.simplify_conj/10-0 (det) (simplify_goal_conj.m:285 and others)
  13 pred check_hlds.simplify.simplify_goal_conj.simplify_goal_plain_conj/10-0 (det) (simplify_goal_conj.m:82)
  14 pred check_hlds.simplify.simplify_goal.simplify_goal_expr/10-0 (det) (simplify_goal.m:331)
  15 pred check_hlds.simplify.simplify_goal.simplify_goal/8-0 (det) (simplify_goal.m:285)
  16 2* pred check_hlds.simplify.simplify_goal_switch.simplify_switch_cases/15-0 (det) (simplify_goal_switch.m:278 and others)
  18 pred check_hlds.simplify.simplify_goal_switch.simplify_goal_switch/10-0 (det) (simplify_goal_switch.m:85)
  19 pred check_hlds.simplify.simplify_goal.simplify_goal_expr/10-0 (det) (simplify_goal.m:344)
  20 pred check_hlds.simplify.simplify_goal.simplify_goal/8-0 (det) (simplify_goal.m:285)
  21 pred check_hlds.simplify.simplify_proc.do_simplify_top_level_goal/6-0 (det) (simplify_proc.m:708)
  22 pred check_hlds.simplify.simplify_proc.simplify_top_level_goal/7-0 (det) (simplify_proc.m:611)
  23 pred check_hlds.simplify.simplify_proc.simplify_goal_update_vars_in_proc/11-0 (det) (simplify_proc.m:201)
  24 pred transform_hlds.pd_util.pd_simplify_goal/5-0 (det) (pd_util.m:264)
  25 pred transform_hlds.deforest.push_goal_into_goal/8-0 (det) (deforest.m:1844)
  26 pred transform_hlds.deforest.handle_deforestation/9-0 (det) (deforest.m:761)
  27 3* pred transform_hlds.deforest.deforest_conj/6-0 (det) (deforest.m:566 and others)
  30 pred transform_hlds.deforest.deforest_goal_expr/6-0 (det) (deforest.m:319)
  31 pred transform_hlds.deforest.deforest_goal/4-0 (det) (deforest.m:294)
  32 pred transform_hlds.deforest.deforest_proc_deltas/5-0 (det) (deforest.m:230)
  33 pred transform_hlds.deforest.deforest_proc/3-0 (det) (deforest.m:204)
  34 5* pred list.foldl/4-0 (det) (list.m:3731 and others)
  39 pred transform_hlds.deforest.deforest_module/3-0 (det) (deforest.m:132)
  40 pred top_level.mercury_compile_middle_passes.maybe_deforestation/7-0 (det) (mercury_compile_middle_passes.m:1130)
  41 pred top_level.mercury_compile_middle_passes.middle_pass/10-0 (det) (mercury_compile_middle_passes.m:232)
  42 pred top_level.mercury_compile_main.after_front_end_passes/15-0 (det) (mercury_compile_main.m:2177)
  43 pred top_level.mercury_compile_main.process_augmented_module/17-0 (det) (mercury_compile_main.m:2052)
  44 pred top_level.mercury_compile_main.augment_and_process_module/15-0 (det) (mercury_compile_main.m:1926)
  45 pred list.map_foldl3/9-0 (det) (list.m:4080)
  46 pred top_level.mercury_compile_main.augment_and_process_all_submodules/16-0 (det) (mercury_compile_main.m:1872)
  47 pred top_level.mercury_compile_main.read_augment_and_process_module_ok/17-0 (det) (mercury_compile_main.m:1730)
  48 pred top_level.mercury_compile_main.read_augment_and_process_module/15-0 (det) (mercury_compile_main.m:1672)
  49 pred top_level.mercury_compile_main.do_process_compiler_arg/13-0 (det) (mercury_compile_main.m:1238)
  50 pred top_level.mercury_compile_main.setup_and_process_compiler_arg/17-0 (det) (mercury_compile_main.m:1102)
  51 pred top_level.mercury_compile_main.setup_and_process_compiler_cmd_line_args/19-0 (det) (mercury_compile_main.m:1013)
  52 pred top_level.mercury_compile_main.do_op_mode_args/16-0 (det) (mercury_compile_main.m:859)
  53 pred top_level.mercury_compile_main.do_op_mode/14-0 (det) (mercury_compile_main.m:662)
  54 pred top_level.mercury_compile_main.main_after_setup/9-0 (det) (mercury_compile_main.m:614)
  55 pred top_level.mercury_compile_main.real_main_after_expansion/5-0 (det) (mercury_compile_main.m:315)
  56 pred top_level.mercury_compile_main.real_main/2-0 (det) (mercury_compile_main.m:153)
  57 pred mercury_compile.main/2-0 (det) (mercury_compile.m:32)
TagsNo tags attached.
Attached Files? bug.m (2,436) 2023-12-13 13:20
https://bugs.mercurylang.org/file_download.php?file_id=327&type=bug

There are no notes attached to this issue.

Issue History
2023-12-13 13:20wangpNew Issue
2023-12-13 13:20wangpFile Added: bug.m
2023-12-13 19:06zsAssigned To => zs
2023-12-13 19:06zsStatusnew => assigned