Unbreak hyphenated prefixed names
- Dominant language
- Rust
- Stars
- 289
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
Consider `foo.ttl` with
```turtle
@prefix eg: .
eg:foo eg:a-property 42 .
```
and a program
```prolog
@prefix eg: .
@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.
Contributor guide
Research direction
Reproduce the issue with the provided foo.ttl Turtle input and Prolog program, then inspect the parsing and diagnostic behavior for hyphenated and percent-containing names. Done means prefixed names from RDF graphs no longer cause silent output failures, and clearly invalid constant arithmetic produces a diagnostic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100