jayvee icon indicating copy to clipboard operation
jayvee copied to clipboard

[BUG] `InternalRepresentationParserVisitor.value` is `undefined` despite being typed as `string`

Open jrentlez opened this issue 11 months ago • 0 comments

Steps to reproduce

  1. Remove the type guard in InternalRepresentationParserVisitor.trim()
  2. run npx nx run interpreter:test

Description

  • Expected: All tests succeed
  • Actual:
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯________________⎯⎯⎯⎯ Failed Tests 1⎯⎯⎯⎯⎯⎯⎯_________________________________________⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
 FAIL  src/examples-smoke-test.spec.ts > jv example smoke tests > should have no errors when executing gtfs-static.jv example
AssertionError: false == true

- Expected
+ Received

- true
+ false

 ❯ ExecutionContext.exitNode ../../libs/execution/src/lib/execution-context.ts:75:5
     73|   public exitNode(node: StackNode) {
     74|     const poppedNode = this.stack.pop();
     75|     assert(poppedNode === node);
       |     ^
     76|
     77|     this.updateLoggingContext();
 ❯ Module.executeBlocks ../../libs/execution/src/lib/blocks/block-execution-util.ts:77:22
 ❯ DefaultJayveeInterpreter.runPipeline ../../libs/interpreter-lib/src/interpreter.ts:322:29
 ❯ DefaultJayveeInterpreter.interpretJayveeProgram ../../libs/interpreter-lib/src/interpreter.ts:279:23
 ❯ DefaultJayveeInterpreter.interpretProgram ../../libs/interpreter-lib/src/interpreter.ts:156:36
 ❯ DefaultJayveeInterpreter.interpretFile ../../libs/interpreter-lib/src/interpreter.ts:182:12
 ❯ Module.runAction src/run-action.ts:54:20
 ❯ src/examples-smoke-test.spec.ts:215:5

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯___________________________________________________________________⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

 Test Files  1 failed | 1 passed (2)
      Tests  1 failed | 5 passed (6)
   Start at  14:20:53
   Duration  4.78s (transform 538ms, setup 0ms, collect 1.95s, tests 5.00s, environment 429ms, prepare 93ms)


——————————————————————————————————————————————————————————————————

 NX   Ran target test for project interpreter (5s)

   ✖  1/1 failed
   ✔  0/1 succeeded [0 read from cache]

During the test, the following error is emitted:

stderr | src/examples-smoke-test.spec.ts > jv example smoke tests > should have no errors when executing gtfs-static.jv example
                error: An unknown error occurred: TypeError: Cannot read properties of undefined (reading 'trimStart')
    at InternalRepresentationParserVisitor.trim (/home/jonas/Code/uni/hiwi/jayvee/libs/execution/src/lib/types/value-types/internal-representation-parsing.ts:55:31)
    at InternalRepresentationParserVisitor.visitInteger (/home/jonas/Code/uni/hiwi/jayvee/libs/execution/src/lib/types/value-types/internal-representation-parsing.ts:73:10)
    at IntegerValuetype.acceptVisitor (/home/jonas/Code/uni/hiwi/jayvee/libs/language-server/src/lib/ast/wrappers/value-type/primitive/integer-value-type.ts:17:20)
    at InternalRepresentationParserVisitor.visitAtomicValueType (/home/jonas/Code/uni/hiwi/jayvee/libs/execution/src/lib/types/value-types/internal-representation-parsing.ts:87:22)
    at AtomicValueType.acceptVisitor (/home/jonas/Code/uni/hiwi/jayvee/libs/language-server/src/lib/ast/wrappers/value-type/atomic-value-type.ts:36:20)
    at Module.parseValueToInternalRepresentation (/home/jonas/Code/uni/hiwi/jayvee/libs/execution/src/lib/types/value-types/internal-representation-parsing.ts:30:28)
    at TableInterpreterExecutor.parseAndValidateValue (/home/jonas/Code/uni/hiwi/jayvee/libs/extensions/tabular/exec/src/lib/table-interpreter-executor.ts:221:25)
    at /home/jonas/Code/uni/hiwi/jayvee/libs/extensions/tabular/exec/src/lib/table-interpreter-executor.ts:187:32
    at Array.forEach (<anonymous>)
    at TableInterpreterExecutor.constructAndValidateTableRow (/home/jonas/Code/uni/hiwi/jayvee/libs/extensions/tabular/exec/src/lib/table-interpreter-executor.ts:181:19)
    at /home/jonas/Code/uni/hiwi/jayvee/libs/extensions/tabular/exec/src/lib/table-interpreter-executor.ts:152:29
    at Array.forEach (<anonymous>)
    at Sheet.iterateRows (/home/jonas/Code/uni/hiwi/jayvee/libs/execution/src/lib/types/io-types/sheet.ts:58:15)
    at TableInterpreterExecutor.constructAndValidateTable (/home/jonas/Code/uni/hiwi/jayvee/libs/extensions/tabular/exec/src/lib/table-interpreter-executor.ts:147:11)
    at TableInterpreterExecutor.doExecute (/home/jonas/Code/uni/hiwi/jayvee/libs/extensions/tabular/exec/src/lib/table-interpreter-executor.ts:114:33)
    at TableInterpreterExecutor.execute (/home/jonas/Code/uni/hiwi/jayvee/libs/execution/src/lib/blocks/block-executor.ts:39:40)
                $In /stdlib/domain/mobility/GTFSStopTimesInterpreter.jv:28:11
                28 |     block StopTimesTableInterpreter oftype TableInterpreter {
                   |           ^^^^^^^^^^^^^^^^^^^^^^^^^

This occurs, because the trim() method tries to access this.value.trimStart(), but this.value is undefined despite being typed as string.

jrentlez avatar Feb 04 '25 13:02 jrentlez