Skip to content
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

anon compiler regression #156

Open
Saiv46 opened this issue Jun 9, 2024 · 1 comment
Open

anon compiler regression #156

Saiv46 opened this issue Jun 9, 2024 · 1 comment

Comments

@Saiv46
Copy link
Contributor

Saiv46 commented Jun 9, 2024

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/[email protected]/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/[email protected]/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/[email protected]/node_modules/protodef/src/datatypes/compiler-structures.js:138:16)
    at SizeOfCompiler.compileType (/home/alexander/MEGA/Projects/github:Saiv46/nut-parser/node_modules/.pnpm/[email protected]/node_modules/protodef/src/compiler.js:397:90)
    at SizeOfCompiler.generate (/home/alexander/MEGA/Projects/github:Saiv46/nut-parser/node_modules/.pnpm/[email protected]/node_modules/protodef/src/compiler.js:235:34)
    at ProtoDefCompiler.compileProtoDefSync (/home/alexander/MEGA/Projects/github:Saiv46/nut-parser/node_modules/.pnpm/[email protected]/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"
          }
        ]
      ]
    }
  }
}
@Saiv46 Saiv46 changed the title container anon compiler regression anon compiler regression Jun 9, 2024
@Saiv46
Copy link
Contributor Author

Saiv46 commented Jun 9, 2024

Documented in ProtoDef-io/ProtoDef#53

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

No branches or pull requests

1 participant