2024-10-11 19:08 AEDT

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000086mercuryBugpublic2015-11-02 13:08
Reporteruser90 
Assigned Tojuliensf 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
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

-Relationships
+Relationships

-Notes

~0000860

juliensf (administrator)

This was fixed in commit 491bb0a.
+Notes

-Issue History
Date Modified Username Field Change
2008-09-29 11:05 user90 New Issue
2015-11-02 13:08 juliensf Note Added: 0000860
2015-11-02 13:08 juliensf Status new => resolved
2015-11-02 13:08 juliensf Resolution open => fixed
2015-11-02 13:08 juliensf Assigned To => juliensf
+Issue History