Mercury Bugs - mercury
View Issue Details
0000580mercuryFeature Requestpublic2026-01-15 14:102026-01-27 03:23
Reporterwangp 
Assigned Tozs 
PrioritynormalSeverityfeatureReproducibilityalways
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000580: parse foreign_proc body into comments vs non-comments
DescriptionIt should be relatively easy to parse C/C#/Java foreign_proc bodies into comments and non-comment sections. Then we could avoid false positive warnings about "return" statements when the word "return" appears within a comment.

There are cases where we deliberately name a variable within a comment to suppress a warning about a variable not occurring, but perhaps in those cases the variable would have an underscore prefix, e.g.

:- pragma foreign_proc("C#",
    min(_Array::in, Min::out),
    [will_not_call_mercury, promise_pure, thread_safe],
"
    // Array not used.
    Min = 0;
").

Also, in C at least, that code could have been written as (void)Array;
TagsNo tags attached.
Attached Files

Notes
(0001239)
zs   
2026-01-27 03:23   
Would anyone object if, as part of the fix, I changed the compiler to check both the argument lists and the bodies of *all* foreign_procs, and not just of the foreign_procs that happen to be for the current backend?

Issue History
2026-01-15 14:10wangpNew Issue
2026-01-27 03:21zsAssigned To => zs
2026-01-27 03:21zsStatusnew => assigned
2026-01-27 03:23zsNote Added: 0001239