Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant