Skip to content

anon compiler regression #156

Description

@Saiv46

anon type only works for directly defined containers.
Also it probably should work with other types besides container/bitfield (like ({ a, ...null, b })).

/home/alexander/MEGA/Projects/github:Saiv46/nut-parser/node_modules/.pnpm/protodef@1.15.0/node_modules/protodef/src/datatypes/compiler-structures.js:231
        throw new Error('Cannot inline anonymous type: ' + type)
        ^

Error: Cannot inline anonymous type: closure
    at containerInlining (/home/alexander/MEGA/Projects/github:Saiv46/nut-parser/node_modules/.pnpm/protodef@1.15.0/node_modules/protodef/src/datatypes/compiler-structures.js:231:15)
    at module.exports.SizeOf.container (/home/alexander/MEGA/Projects/github:Saiv46/nut-parser/node_modules/.pnpm/protodef@1.15.0/node_modules/protodef/src/datatypes/compiler-structures.js:138:16)
    at SizeOfCompiler.compileType (/home/alexander/MEGA/Projects/github:Saiv46/nut-parser/node_modules/.pnpm/protodef@1.15.0/node_modules/protodef/src/compiler.js:397:90)
    at SizeOfCompiler.generate (/home/alexander/MEGA/Projects/github:Saiv46/nut-parser/node_modules/.pnpm/protodef@1.15.0/node_modules/protodef/src/compiler.js:235:34)
    at ProtoDefCompiler.compileProtoDefSync (/home/alexander/MEGA/Projects/github:Saiv46/nut-parser/node_modules/.pnpm/protodef@1.15.0/node_modules/protodef/src/compiler.js:42:44)
    at Object.<anonymous> (/home/alexander/MEGA/Projects/github:Saiv46/nut-parser/protodef.js:52:27)
    at Module._compile (node:internal/modules/cjs/loader:1434:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)
    at Module.load (node:internal/modules/cjs/loader:1249:32)
    at Module._load (node:internal/modules/cjs/loader:1065:12)

Node.js v22.2.0

Protocol definition to reproduce:

{
  "types": {
    "void": "native",
    "container": "native"
  },
  "sqirrel": {
    "types": {
      "closure": [
        "container",
        [
          {
            "name": "main",
            "type": "void"
          }
        ]
      ],
      "script": [
        "container",
        [
          {
            "anon": true,
            "type": "closure"
          }
        ]
      ]
    }
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions