mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-24 13:53:54 +00:00
Estimated hours taken: 1 Branches: main compiler/ml_string_switch.m: Fix a compiler abort when generating code for determistic string switches. tests/valid/Mmakefile: tests/valid/det_string_switch.m: Add test case.
35 lines
720 B
Mathematica
35 lines
720 B
Mathematica
% This is a regression test for a bug in MLDS code generation where it would
|
|
% abort while generating the code of a deterministic string switch.
|
|
%
|
|
% Uncaught Mercury exception:
|
|
% Software Error: ml_code_util.m: Unexpected: ml_gen_failure: `fail' has determinism `det'
|
|
|
|
:- module det_string_switch.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
% Need this many cases to make a string switch.
|
|
:- inst bar
|
|
---> "a"
|
|
; "b"
|
|
; "c"
|
|
; "d"
|
|
; "e"
|
|
; "f"
|
|
; "g"
|
|
; "h".
|
|
|
|
:- pred foo(string::in(bar), io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
foo("a", !IO).
|
|
foo("b", !IO).
|
|
foo("c", !IO).
|
|
foo("d", !IO).
|
|
foo("e", !IO).
|
|
foo("f", !IO).
|
|
foo("g", !IO).
|
|
foo("h", !IO).
|