mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 02:43:40 +00:00
This fixes Mantis bug #486. compiler/parse_pragma.m: Read in the name of the type in a foreign enum in whatever qualified form it is in the source code, and then try to implicitly qualify it, generating a specific error message if that attempt is unsuccessful. compiler/parse_sym_name.m: To make the above possible, expose the code that does the implicit qualification. Do so not just in the form now needed by parse_pragma.m, but in the other forms used by other predicates in parse_sym_name.m as well, since they probably will be needed sooner or later. (The lack of such separated-out capability is what led to the code that caused bug 486 in the first place.) Avoid an unneeded asymmetry by providing mechanisms to parse implicitly qualified sym_names without arguments, as well as with arguments. compiler/parse_util.m: Give several of the predicates involved in the above more expressive names. compiler/parse_inst_mode_defn.m: compiler/parse_type_defn.m: compiler/parse_type_repn.m: compiler/recompilation.check.m: Conform to the changes above. compiler/error_util.m: Fix a bug that silently deleted the newly-added simplest_specs, which this diff uses for the first time. Add determinism requirements to avoid similar problems in the future. compiler/add_foreign_enum.m: Note that the old code that diagnosed attempts to define foreign_enums for types in other modules should not be needed anymore. tests/invalid/foreign_enum_import.err_exp: Expect the error message now generated by parse_pragma.m, which is more specific than the one generated by add_foreign_enum.m until now. tests/valid/bug486.m: tests/valid/bug486.window.m: A regression test for the bug. tests/valid/Mmakefile: Enable the new test.
36 lines
977 B
Mathematica
36 lines
977 B
Mathematica
%-----------------------------------------------------------------------------%
|
|
% vim: ft=mercury ts=4 sw=4 et
|
|
%-----------------------------------------------------------------------------%
|
|
%
|
|
% This regression test for Mantis bug #486 is cut down from code that was
|
|
% originally in extras/graphics/mercury_glut/glut.window.m.
|
|
%
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- module bug486.window.
|
|
:- interface.
|
|
|
|
:- type window.state
|
|
---> x
|
|
; y
|
|
; window_width
|
|
; window_height.
|
|
|
|
:- implementation.
|
|
|
|
:- pragma foreign_decl("C",
|
|
"
|
|
#define GLUT_WINDOW_X 41
|
|
#define GLUT_WINDOW_Y 42
|
|
#define GLUT_WINDOW_WIDTH 43
|
|
#define GLUT_WINDOW_HEIGHT 44
|
|
").
|
|
|
|
:- pragma foreign_enum("C", window.state/0,
|
|
[
|
|
x - "GLUT_WINDOW_X",
|
|
y - "GLUT_WINDOW_Y",
|
|
window_width - "GLUT_WINDOW_WIDTH",
|
|
window_height - "GLUT_WINDOW_HEIGHT"
|
|
]).
|