Length throws TypeError when its null operand is not an As expression (e.g. an expression reference)

Abierto
#412 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
65/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
javascript
Área
api, backend

Línea de trabajo

Start with Length.exec in src/elm/overloaded.ts and inspect the translated ELM signature and operand result type mentioned in the issue. Reproduce with the LengthNull examples, checking both expression references and typed null literals. Done when Length(S) returns null and Length(LS) returns 0 without throwing; the issue does not name a test file.

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

Descripción

Length throws a TypeError when its argument is null and the operand is not an As expression, for example an expression reference. The typed null literal forms work.

library LengthNull version '1.0.0'

define S: null as String
define LS: null as List<Integer>

define LengthOfNullStringLiteral: Length(null as String)          // null
define LengthOfNullStringRef: Length(S)                            // TypeError
define LengthOfNullListLiteral: Length(null as List<Integer>)      // 0
define LengthOfNullListRef: Length(LS)                             // TypeError

Error for the two failing definitions:

Encountered unexpected error during execution.

	Error Message:	Cannot read properties of undefined (reading 'type')
	CQL Library:	LengthNull|1.0.0
	Expression:	Length

Expected:

  • Length(S): null, as for a null String (Appendix B; cql-tests LengthNullString);
  • Length(LS): 0, as for a null List (Appendix B; see also #168).

Cause: for a null argument, Length.exec reads this.arg.asTypeSpecifier.type. Only an As operand has asTypeSpecifier; for an ExpressionRef it is undefined:

https://github.com/cqframework/cql-execution/blob/master/src/elm/overloaded.ts#L322

The ELM already carries what is needed to choose the overload. In the translated library above, every Length element has a signature (NamedTypeSpecifier String or ListTypeSpecifier), and the operand has resultTypeName / resultTypeSpecifier. A possible fix is to use the signature or the operand's result type, and not to throw when no type information is present.

Environment:

  • cql-execution 3.3.2 and 4.0.0-beta.1 (same line in both);
  • ELM from @cqframework/cql 5.8.0 (npm), with EnableResultTypes;
  • Node 24, Windows 11.

The reference engine has the same pattern: cqframework/clinical_quality_language#1976.

Lenguaje dominante
JavaScript
Estrellas
86
Forks
40
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

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 cqframework/cql-execution

Todos los issues de cqframework/cql-execution

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.