View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0000534 | mercury | Bug | public | 2021-05-28 07:32 | 2021-05-28 07:32 | ||||||||
Reporter | emacstheviking | ||||||||||||
Assigned To | |||||||||||||
Priority | normal | Severity | crash | Reproducibility | always | ||||||||
Status | new | Resolution | open | ||||||||||
Platform | Apple | OS | Catalina | OS Version | 10.15.7 | ||||||||
Product Version | |||||||||||||
Target Version | Fixed in Version | ||||||||||||
Summary | 0000534: Uncaught Mercury exception when using try[] on predicate optimsied away to true? | ||||||||||||
Description | Whilst trying to use try/catch, I was calling a predicate that attempted to abstract away the perceived repetition of using trace[]. I created a local predicate, atrace, which then calls a more common code ftrace, the intent was to be able to abstract out the check for an environment variable being present and then only cause output to happen of the debug level of that variable was past a given threshold. Zoltan says all three predicates are effectively useless, which I can almost understand, but nonetheless it caused the compiler to choke on my awful code. Thank you. | ||||||||||||
Steps To Reproduce | This code: on_lexer(Lx, AST) :- AST = astcon, list.filter_map(promote, lexer.tokens(Lx), ATokens), atrace("after promotion: %s\n\n--", [s(string(ATokens))]), ( try [] ast([], Tree, ATokens, Rest) then atrace("then block, Rest: %s\n", [s(string(Rest))]) else atrace("else block\n", []) catch syntax_error(Pos, Why) -> atrace("oops: %s at %s", [s(Why), s(string(Pos))]) ). coupled with the following implementation of atrace and ftrace gave rise to the issue. :- pred atrace(string::in, list(string.poly_type)::in) is det. atrace(Format, Args) :- atrace(0, Format, Args). :- pred atrace(int::in, string::in, list(string.poly_type)::in) is det. atrace(Level, Format, Args) :- utils.ftrace(Level, "FELT_AST", "\n", Format, Args). and :- pred ftrace( int::in, string::in, string::in, string::in, list(string.poly_type)::in) is det. ftrace(Level, Flag, Prefix, Format, Args) :- trace[io(!Dbg)] ( utils.get_env_int(Flag, 0, N, !Dbg), (if N >= Level then io.print(Prefix, !Dbg), io.format(Format, Args, !Dbg) else true) ). | ||||||||||||
Additional Information | Mercury Compiler, version 20.06.1, on x86_64-apple-darwin19.6.0 Copyright (C) 1993-2012 The University of Melbourne Copyright (C) 2013-2020 The Mercury team Usage: mmc [<options>] <arguments> Use `mmc --help' for more information. | ||||||||||||
Tags | No tags attached. | ||||||||||||
Attached Files |
|
Issue History | |||
Date Modified | Username | Field | Change |
---|---|---|---|
2021-05-28 07:32 | emacstheviking | New Issue |