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

yaml: imported fields treated as type none #461

Open
triodan opened this issue Mar 24, 2024 · 1 comment
Open

yaml: imported fields treated as type none #461

triodan opened this issue Mar 24, 2024 · 1 comment

Comments

@triodan
Copy link

triodan commented Mar 24, 2024

  • Component:
    • VSCode Extension
  • Extension version: v0.13.0
  • LSP version:
  • OS version and name: Windows 11
  • I am on the latest stable version of the extension/LSP.
  • I have searched the issues of this repo and believe that this is not a duplicate.

Issue

When a YAML file is imported and passed to a method, the receiving method treats the passed data as type none.

main.typ:

#let print_name(content) = [
  #for item in content [
    #item.name
  ]
]

#print_name(
  yaml("data.yaml")
)

data.yaml:

- name: Alice
- name: Bob

VSCode will report this error despite compilation preview being successful:
image

@triodan
Copy link
Author

triodan commented Mar 24, 2024

I figured out that this is caused due to lack of null-checking for the passed-in variables. Adding checks like this in the function resolves the issue:

#if content != none {
 ...
}

However I think the current message is not intuitive, maybe it can be replaced with something like 'content' may be of type none?

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