Skip to content

Prop punning when types don't match results in I/O error: _none_: No such file or directory #7532

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

Closed
mediremi opened this issue May 29, 2025 · 3 comments · Fixed by #7533
Closed

Comments

@mediremi
Copy link
Contributor

For version v12.0.0-alpha.14 (commit e63147f), using component prop punning with mismatched types results in I/O error: _none_: No such file or directory:

module Level2 = {
  @react.component
  let make = (~someProp: float) => {
    React.null
  }
}

module Level1 = {
  @react.component
  let make = (~someProp: array<int>) => {
    <Level2 someProp />
  }
}
FAILED: File.cmj

  We've found a bug for you!
  /home/mediremi/test/File.res

  I/O error: _none_: No such file or directory

In v12.0.0-alpha.12 & v12.0.0-alpha.13, a type error is shown but without any line numbers:

FAILED: File.cmj

  We've found a bug for you!
  /home/mediremi/test/File.res

  This has type: array<int>
  But it's expected to have type: float

(Playground link for v12.0.0-alpha.13)

In v12.0.0-alpha.11 and below, full location information is included in the error:

FAILED: File.cmj

  We've found a bug for you!
  /home/mediremi/test/File.res:11:15-22

   9 │  @react.component
  10 │     let make = (~someProp: array<int>) => {
  11 │       <Level2 someProp />
  12 │     }
  13 │ }

  This has type: array<int>
  But it's expected to have type: float
@mediremi
Copy link
Contributor Author

The error message is coming from this exception handler in compiler/ml/location.ml:

let () =
register_error_of_exn (function
| Sys_error msg ->
Some (errorf ~loc:(in_file !input_name) "I/O error: %s" msg)

And _none_ comes from the initial value of the input_name ref:

let input_name = ref "_none_"

@mediremi
Copy link
Contributor Author

If punning isn't used, the error message is fine:

module Level2 = {
  @react.component
  let make = (~someProp: float) => {
    React.null
  }
}

module Level1 = {
  @react.component
  let make = (~someProp: array<int>) => {
    <Level2 someProp=someProp />
  }
}
FAILED: File.cmj

  We've found a bug for you!
  /home/mediremi/test/File.res:11:24-31

   9 │  @react.component
  10 │     let make = (~someProp: array<int>) => {
  11 │       <Level2 someProp=someProp />
  12 │     }
  13 │ }

  This has type: array<int>
  But it's expected to have type: float

Playground link

@nojaf
Copy link
Collaborator

nojaf commented May 29, 2025

I have a hunch. Let me check later tonight

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 a pull request may close this issue.

2 participants