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

Unbreak hyphenated prefixed names #624

Open
mmarx opened this issue Feb 27, 2025 · 0 comments
Open

Unbreak hyphenated prefixed names #624

mmarx opened this issue Feb 27, 2025 · 0 comments
Labels
Parser Rule-Parser-Related Issue rdf RDF support

Comments

@mmarx
Copy link
Member

mmarx commented Feb 27, 2025

Consider foo.ttl with

@prefix eg: <https://example.org/> .

eg:foo eg:a-property 42 .

and a program

@prefix eg: <https://example.org/> .
@import triple :- turtle{resource="foo.ttl"} .

foo(?x, ?y) :- triple(?x, eg:a-property, ?y) .
@export foo :- csv{resource=""} .

This will not output anything, since - is no longer allowed as part of names (cf. #545). It will also not output any diagnostics. We have thus traded an unwarranted (yet, arguably, helpful) diagnostic

result(?arithmetic-1) :- fact(?arithmetic) .
       ──────┬──────
             ╰──────── unsafe variable used in rule head: `?arithmetic-1`

Help: a variable with a similar name exists: `arithmetic`

Note: every universal variable in the head must occur at a safe position in the body

that makes it quite obvious what the issue is (and how to fix it) for silently ignoring parts of the program. From a user experience standpoint, this is much worse. Also note that the same issue as #543 still persists with %, which we still allow in names (it's used for escape sequences in prefixed names). This is also even worse than the potential problem outlined in #545 and #546, in that I can easily change the prefix names I define in the program, but I have to work with the local names I get from upstream RDF graphs, and always using fully expanded IRIs is a terrible experience.

First of all, we should probably not treat variable names, plain constants, and prefixed names the same – there's no good reason a variable name should be able to contain a - or an % (there might be other characters that cause confusion with builtin operators as well). Second, we should have diagnostics for clearly ill-formed rules: subtracting a constant from a constant should be a syntax error (or, at the very least, a warning) – how could this ever be interpreted as a valid rule (note that, e.g., this problem doesn't arise in SPARQL, as constant names are not allowed in arithmetic expressions there)? This would then allow us to accept - and % in both the prefix name and the local name of a prefixed name.

@mmarx mmarx added Parser Rule-Parser-Related Issue rdf RDF support labels Feb 27, 2025
@mmarx mmarx added this to nemo Feb 27, 2025
@github-project-automation github-project-automation bot moved this to Todo in nemo Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Parser Rule-Parser-Related Issue rdf RDF support
Projects
Status: Todo
Development

No branches or pull requests

1 participant