Mercury Bugs - mercury
View Issue Details
0000086mercuryBugpublic2008-09-29 11:052015-11-02 13:08
Reporteruser90 
Assigned Tojuliensf 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000086: Uncaught mode error leads to crash in codegen.m
DescriptionThe following program:

%-----------------------------------------------------------------------------%
:- module hello.
:- interface.
:- import_module io.

:- pred main(io::di, io::uo) is det.

:- implementation.
:- import_module string.

:- type abc ---> a ; b ; c.
:- inst ab ---> a ; b.

:- func abc2ab(abc::in) = (abc::out(ab)) is det.

abc2ab(X) = X.

main(!IO) :-
    X = abc2ab(c),
    io.write_string("X = " ++ X^string, !IO).
%-----------------------------------------------------------------------------%

Makes the compiler abort:

  Uncaught Mercury exception:
  Software Error: code_gen.m: Unexpected: semidet model in det context
  Stack dump not available in this grade.

A similar case: if I change 'main' to this:

main(!IO) :-
    X = abc2ab(c),
    ( X = a,
        io.write_string("X = a: " ++ X^string, !IO)
    ;
        X = b,
        io.write_string("X = b: " ++ X^string, !IO)
    ;
        X = c,
        io.write_string("X = c: " ++ X^string, !IO)
    ).

I get a compiler warning:

  hello.m:029: In clause for `main(di, uo)':
  hello.m:029: warning: unification of `X' and hello.c cannot succeed
  hello.m:029: `X' has instantiatedness `bound((hello.a) ; (hello.b))'.

and then codegen.m aborts again -- I guess the 'X=c' branch is removed as
dead code.
TagsNo tags attached.
Attached Files

Notes
(0000860)
juliensf   
2015-11-02 13:08   
This was fixed in commit 491bb0a.

Issue History
2008-09-29 11:05user90New Issue
2015-11-02 13:08juliensfNote Added: 0000860
2015-11-02 13:08juliensfStatusnew => resolved
2015-11-02 13:08juliensfResolutionopen => fixed
2015-11-02 13:08juliensfAssigned To => juliensf