mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-29 00:04:55 +00:00
Branches: main
In the Java grade, an enumeration is represented by a class with a `value'
field, alongside constants named by the user. A constant named `value'
would conflict with that field, so we rename it to `MR_value'.
compiler/ml_type_gen.m:
compiler/mlds_to_java.m:
As above.
tests/hard_coded/Mmakefile:
tests/hard_coded/value_enum.exp:
tests/hard_coded/value_enum.m:
Add test case.
26 lines
656 B
Mathematica
26 lines
656 B
Mathematica
% The Java backend was using `value' as a field name inside enumeration
|
|
% classes, which conflicted with `value' function symbols in Mercury code.
|
|
|
|
:- module value_enum.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- type ref_or_value
|
|
---> value
|
|
; ref.
|
|
|
|
main(!IO) :-
|
|
io.write(value, !IO),
|
|
io.nl(!IO).
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
% vim: ft=mercury ts=8 sts=4 sw=4 et
|