unison/unison-src/transcripts/doc-type-link-keywords.md
Nicole Prindle 8e3acc32ee
Fix lexing in embedded type links in docs
A doc containing an embedded term link in a doc like
`{{a doc linking to {abilityFoo}}}` would previously eagerly lex
`ability` or `type` as a keyword, tricking the parser into thinking
we're in an embedded type link, and then complain about not finding
`Foo`. This fixes the lexer to treat such cases as term links instead.

Adds a regression test transcript for making sure that `type` and
`ability` are lexed properly in type and term links in docs.
2022-02-02 02:00:37 -05:00

1.0 KiB

Regression test to ensure that type and ability in embedded doc links are lexed properly when they occur at the start of identifiers.

That is, {abilityPatterns} should be a link to the term abilityPatterns, not the ability Patterns; the lexer should see this as a single identifier.

See https://github.com/unisonweb/unison/issues/2642 for an example.

.> builtins.mergeio
abilityPatterns : ()
abilityPatterns = ()

structural ability Patterns where p : ()

typeLabels : Nat
typeLabels = 5

structural type Labels = Labels

docs.example1 = {{A doc that links to the {abilityPatterns} term}}
docs.example2 = {{A doc that links to the {ability Patterns} ability}}
docs.example3 = {{A doc that links to the {typeLabels} term}}
docs.example4 = {{A doc that links to the {type Labels} type}}
.> add

Now we check that each doc links to the object of the correct name:

.> display docs.example1
.> display docs.example2
.> display docs.example3
.> display docs.example4