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

list() does not always return an iterator #61

Closed
LaurensRietveld opened this issue Sep 23, 2021 · 5 comments
Closed

list() does not always return an iterator #61

LaurensRietveld opened this issue Sep 23, 2021 · 5 comments

Comments

@LaurensRietveld
Copy link

LaurensRietveld commented Sep 23, 2021

The function description of list() says that it always returns an iterator. In reality, it does not:

 if (this.term) {
      if (this.term.termType !== 'NamedNode' && this.term.termType !== 'BlankNode') {
        return null
      }

      if (!this.term.equals(this.namespace.nil) && !this.out(this.namespace.first).term) {
        return null
      }
    }

This causes issues in e.g. the shacl validator where a spread operator is applied to the list() result (see here)

Depending on the structure of your data, this leads to obscure errors such as listNode.list is not a function or its return value is not iterable

@l00mi l00mi added the bug label Sep 23, 2021
@l00mi
Copy link
Contributor

l00mi commented Sep 23, 2021

Thank you for pointing this out.

* @returns {Iterable | null}
states that it can return null. Do you refer to something else?

@bergos do you remember why we went for null over an empty list?

@martinmaillard can https://github.com/zazuko/rdf-validate-shacl deal with this?

@LaurensRietveld
Copy link
Author

Ah, I mistakenly added links to files instead of lines. I wanted to refer to this line. You're right in that the @returns tag is correct here.

Let me know if the validate-shacl library is a better place for ticket and I'll make an issue there

@tpluscode tpluscode removed the bug label Sep 23, 2021
@tpluscode
Copy link
Contributor

This is by design, IIRC to distinguish between an empty list ( ) and a non-list

@LaurensRietveld
Copy link
Author

thanks! I'll report this in the validate-shacl repo then

@LaurensRietveld
Copy link
Author

see zazuko/rdf-validate-shacl#73

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

3 participants