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

TypeError: Expected string for scope, got undefined #5

Open
TheWitheredStriker opened this issue Nov 14, 2023 · 9 comments
Open

TypeError: Expected string for scope, got undefined #5

TheWitheredStriker opened this issue Nov 14, 2023 · 9 comments
Labels
bug Something isn't working external This issue is caused by a dependency partially fixed Part of this problem has been resolved

Comments

@TheWitheredStriker
Copy link

This error keeps happening with most (though not all) of the grammars I'm testing. This includes grammars that don't even have a scope property, like this one.

I'm not sure why this happens, any ideas?

@Nixinova
Copy link
Owner

Will look into this, thanks for the report.

@Nixinova Nixinova added the bug Something isn't working label Nov 18, 2023
@Nixinova
Copy link
Owner

Looks like its an issue with parsing CSON grammar. If i convert your example to JSON then it works fine https://www.convertsimple.com/convert-cson-to-json/. Will see how I can fix this, but that is a workaround in the meantime.

@TheWitheredStriker
Copy link
Author

TheWitheredStriker commented Nov 23, 2023

It doesn't seem to exclusively be a CSON problem. It occurs with YAML too, like this one.

EDIT: I also tried converting the YAML to JSON and I still get the error.

@Nixinova
Copy link
Owner

Looking into it, the error seems to be here:

const tree = starryNight.highlight(sample, grammarJson.scopeName);

When there is an unexpected scopeName property the code doesn't work.

For instance your latest example file:

https://github.com/mitranim/sublime-forth/blob/2293f5c0fd65a141e246880b7c8146affd94c29f/Forth.sublime-syntax#L2-L5

scope: source.forth

It says scope not scopeName.
So I'll have to change the code to take that into account.
Hopefully that fixes this

@Nixinova
Copy link
Owner

Try it now, hopefully fixed.

@TheWitheredStriker
Copy link
Author

I don't get the error anymore, but when trying the Forth grammar, the code is displayed but not highlighted:
image

Trying the CSON Factor grammar up top also still throws the same error. Sorry!

@Nixinova Nixinova reopened this Nov 26, 2023
@Nixinova
Copy link
Owner

Nixinova commented Nov 26, 2023

Hmm that's interesting. Welp, will have to do fix attempt two.

@Nixinova
Copy link
Owner

Ah - this is a bug in the CSON parser, fabiospampinato/cson2json#1.

Seems like it can't handle mixed indents:

repository:
  escaped_characters:
    patterns: true
scope: "source.factor"
scopeName: "source.factor"

image

Will have to switch CSON parser.

@Nixinova Nixinova added the external This issue is caused by a dependency label Aug 11, 2024
@Nixinova
Copy link
Owner

It doesn't seem to exclusively be a CSON problem. It occurs with YAML too, like this one.

EDIT: I also tried converting the YAML to JSON and I still get the error.

The previous fix resolves this problem, but the original issue is with the CSON.

@Nixinova Nixinova added the partially fixed Part of this problem has been resolved label Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working external This issue is caused by a dependency partially fixed Part of this problem has been resolved
Projects
None yet
Development

No branches or pull requests

2 participants