Skip to content

TS bindings break on .scip files generated by rust-analyzer #274

Open
@ephraimrothschild

Description

@ephraimrothschild

I don't know if this should be here, or in the rust-analyzer repo, but something appears incompatible between the two of them. After generating an index using rust-analyzer scip . (using any version of rust-analyzer, and any rust repo), the Typescript bindings fail to parse that index. For example, the following tsx script:

#!/usr/bin/env tsx
import {Command} from 'commander';
import {scip} from './scip';
import * as fs from 'fs';


const program = new Command();

program
  .version("1.0.0")
  .description("")
  .parse(process.argv);

const args = program.args;
const file = fs.readFileSync(args[0], null);
const full_index = scip.Index.deserializeBinary(file);

Running ./testscript.ts ./index.scip
Will cause the following error:

/scripts/node_modules/google-protobuf/google-protobuf.js:13
function ra(a,b,c){return 2>=arguments.length?Array.prototype.slice.call(a,b):Array.prototype.slice.call(a,b,c)};function sa(a,b,c,d){var f="Assertion failed";if(c){f+=": "+c;var h=d}else a&&(f+=": "+a,h=b);throw Error(f,h||[]);}function n(a,b,c){for(var d=[],f=2;f<arguments.length;++f)d[f-2]=arguments[f];a||sa("",null,b,d);return a}function ta(a,b,c){for(var d=[],f=2;f<arguments.length;++f)d[f-2]=arguments[f];"string"!==typeof a&&sa("Expected string but got %s: %s.",[k(a),a],b,d)}
                                                                                                                                                                                                                     ^

Error: Assertion failed
    at sa (/scripts/node_modules/google-protobuf/google-protobuf.js:13:214)
    at n (/scripts/node_modules/google-protobuf/google-protobuf.js:13:311)
    at L (/scripts/node_modules/google-protobuf/google-protobuf.js:74:362)
    at J.gc (/scripts/node_modules/google-protobuf/google-protobuf.js:74:484)
    at Function.deserialize (/scripts/scip.ts:1734:48)
    at <anonymous> (/scripts/scip.ts:726:133)
    at J.Yb (/scripts/node_modules/google-protobuf/google-protobuf.js:67:146)
    at Function.deserialize (/scripts/scip.ts:726:32)
    at <anonymous> (/scripts/scip.ts:298:129)
    at J.Yb (/scripts/node_modules/google-protobuf/google-protobuf.js:67:146)

Node.js v20.16.0

This does not seem to happen with other indexers (eg running this on an index.scip file generated from scip-python, and scip-java do not result in this error, but this occurs no matter which version of rust-analyzer is used). The scip.ts file used is copied directly from sourcegraph/scip/bindings/scip.ts

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions