Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow overriding custom true / false constructors #1175

Merged
merged 7 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Unreleased
([#1147](https://github.com/melange-re/melange/pull/1147))
- Add support for dynamic `import()`
([#1164](https://github.com/melange-re/melange/pull/1164))
- Fix code generation of custom `true` / `false` constructors
([#1175](https://github.com/melange-re/melange/pull/1175))

4.0.1 2024-06-07
---------------
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions test/blackbox-tests/custom-predef.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Demonstrate redefining the `true` / `false` constructors

$ . ./setup.sh
$ cat > x.ml <<EOF
> type t = A | true | false
> let z : t = A
> let x : t = true
> let y : t = false
> let t : bool = false
> EOF

$ melc -ppx melppx x.ml
// Generated by Melange
'use strict';


const z = /* A */0;

const x = /* true */1;

const y = /* false */2;

const t = false;

exports.z = z;
exports.x = x;
exports.y = y;
exports.t = t;
/* No side effect */
2 changes: 1 addition & 1 deletion vendor/melange-compiler-libs