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

Using the function type raises a lexer exception #1195

Closed
SebastienMichoy opened this issue Apr 25, 2022 · 3 comments
Closed

Using the function type raises a lexer exception #1195

SebastienMichoy opened this issue Apr 25, 2022 · 3 comments
Labels

Comments

@SebastienMichoy
Copy link

Describe the bug
Using the function type raises a lexer exception:

Error: parsing expression: Lexer error: could not match text starting at 1:5 failing at 1:7.
	unmatched text: "ty"

Version of yq: 4.24.5
Operating system: mac
Installed via: homebrew

Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
data1.yml:

- "a string"
- "another string"

Command
The command you ran:

yq '. | type' data1.yml

Actual behavior

Error: parsing expression: Lexer error: could not match text starting at 1:5 failing at 1:7.
    unmatched text: "ty"

Expected behavior

"array"

Additional context
I've tried to compare with the output of jq:

$> yq --version
yq (https://github.com/mikefarah/yq/) version 4.24.5
$> jq --version
jq-1.6
$> echo '[0, false, [], {}, null, "hello"]' | yq '. | type'
Error: parsing expression: Lexer error: could not match text starting at 1:5 failing at 1:7.
	unmatched text: "ty"
$> echo '[0, false, [], {}, null, "hello"]' | jq '. | type'
"array"
@mikefarah
Copy link
Owner

Ah I see - in yaml tags represent the type information https://yaml.org/spec/1.2.2/#3212-tags so there is a tag function.

That said - I should create an alias type that calls this, which I can do in the next release. Till then, use tag.

@SebastienMichoy
Copy link
Author

Oh! Thanks for the explanation and the quick response!

mikefarah added a commit that referenced this issue Apr 26, 2022
@mikefarah
Copy link
Owner

Added alias in 4.25.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants