Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Record coercion can construct a private record from outside its module

Abierto
#9,124 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@cknitt ya está trabajando en esto.

Desde el 29/10/2026.

  • #9125 de @cknitt — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
1-2 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
ocaml
Área
compilers

Línea de trabajo

Start by tracing the record coercion type-checking path in the ReScript compiler and compare it with the handling of mutable from #9063, fixed by #9086. Check both examples in this issue: coercion from a plain record and from another module’s private record should be rejected, while coercion out to a plain record should remain allowed. Done means those cases behave as expected and the compiler’s relevant regression tests pass.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

A record coerces structurally into a private record with the same fields, so code outside a module can construct values of that module's private record type, although private means they can only be built inside it.

From a plain record:

module Blob: {
  type t = private {size: float}
} = {
  type t = {size: float}
}

type plain = {size: float}
let fake = (p: plain): Blob.t => (p :> Blob.t)   // compiles: `return p`

From another module's private record with the same fields, which that module constructs freely:

module Fake: {
  type t = private {size: float}
  let make: float => t
} = {
  type t = {size: float}
  let make = size => {size: size}
}

let forged = (Fake.make(1.) :> Blob.t)   // compiles: `{size: 1}`

Expected: a coercion into a private record type is refused, unless the source is that same type. Coercing out of a private record, into a plain record with the same fields, stays allowed: reading a private record is fine.

This is a prerequisite for @instanceOf on private records (#9058): there, a forged value would be dispatched as an instance of a class it isn't. It is the same family as #9063 (fixed by #9086), where record coercion ignored mutable.

Found on master 3562ce6b80.

Lenguaje dominante
OCaml
Estrellas
7.5k
Forks
484
Merge medio
20 h 19 min
PR fusionados (30 d)
242

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rescript-lang/rescript

Todos los issues de rescript-lang/rescript

Issues similares

Más issues de Compilers

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.