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 compilation error in dce.ml. #11779

Merged
merged 1 commit into from
Sep 21, 2024

Conversation

tritao
Copy link
Contributor

@tritao tritao commented Sep 21, 2024

Its my first time hacking on Haxe and I came across the following error. The fix works, but I am not really sure what I am doing with OCaml yet, so is this a proper fix to the error?

This fixes the following compilation error:

File "src/optimization/dce.ml", line 90, characters 13-48:
90 |    List.exists (ExtString.String.starts_with file) dce.std_dirs
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This expression has type prefix:string -> bool
       but an expression was expected of type 'a -> bool
make: *** [Makefile:81: haxe] Error 1

By replacing:

let is_std_file dce file =
	List.exists (ExtString.String.starts_with file) dce.std_dirs

with:

let is_std_file dce file =
	List.exists (fun dir -> ExtString.String.starts_with file dir)
dce.std_dirs

This fixes the following compilation error:

```ocaml
File "src/optimization/dce.ml", line 90, characters 13-48:
90 |    List.exists (ExtString.String.starts_with file) dce.std_dirs
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This expression has type prefix:string -> bool
       but an expression was expected of type 'a -> bool
make: *** [Makefile:81: haxe] Error 1
```

By replacing:

```ocaml
let is_std_file dce file =
	List.exists (ExtString.String.starts_with file) dce.std_dirs
```

with:

```ocaml
let is_std_file dce file =
	List.exists (fun dir -> ExtString.String.starts_with file dir)
dce.std_dirs
```
@Simn
Copy link
Member

Simn commented Sep 21, 2024

What OCaml version are you using? This change is good regardless, I just wonder why this hasn't come up before.

@tritao
Copy link
Contributor Author

tritao commented Sep 21, 2024

What OCaml version are you using? This change is good regardless, I just wonder why this hasn't come up before.

$ ocaml --version
The OCaml toplevel, version 5.2.0
$ opam --version
2.1.6

@Simn Simn merged commit 1ce738c into HaxeFoundation:development Sep 21, 2024
50 checks passed
@Simn
Copy link
Member

Simn commented Sep 21, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants