Skip to content

Remove the /search type-search endpoint - #326

Open
thomashoneyman wants to merge 1 commit into
masterfrom
remove-search-endpoint
Open

thomashoneyman wants to merge 1 commit into
masterfrom
remove-search-endpoint

Conversation

@thomashoneyman

Copy link
Copy Markdown
Member

Description of the change

Removes the compile server's /search type-search endpoint, along with its helpers (tryParseType, lookupAllConstructors, replaceTypeVariablesAndDesugar) and the compiler Environment that only the search used.

The endpoint was added in 2017 as a first stab at type search. Nothing calls it: not the client, nor Pursuit, which has its own type search. It is not documented in the README's Server API section either. It has also been broken since the update to PureScript 0.13 in c9da168: every query, including Int and a -> a, returns {"error":"Cannot parse type"} on production.

  • tryParseType lexes queries with CST.lexTopLevel, which wraps the tokens in TokLayoutStart / TokLayoutEnd, so parseTypeP rejects every query with "Unexpected or mismatched indentation". Pursuit and the compiler's REPL consume those layout tokens; this code did not.
  • With parsing fixed, queries containing type variables crash the request with internalError "Skolem has no kind": since 0.14, unification checks kinds, and the search built kindless skolems and unregistered unknowns.

Fixing both works (I verified a fix locally), but since nothing uses the endpoint, removing it is less code to carry through future compiler upgrades.

Verified locally with PureScript 0.15.17: the server builds with -Wall -Werror; GET /search?q=Int now returns 404; POST /compile still returns JS for a valid program and an UnknownName error for an invalid one.


Checklist:

  • Added the change to the changelog's "Unreleased" section with a reference to this PR (e.g. "- Made a change (#0 by @)")
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation
  • Added a test for the contribution (if applicable)

No client has ever called /search, and it is undocumented. It has
answered every query with "Cannot parse type" since the 0.13 update:
it lexed queries with lexTopLevel, whose layout tokens parseTypeP
rejects. Queries with type variables would also crash the search on
current compilers, which need kinds on its skolems and unknowns.

Remove the route and its helpers, along with the compiler Environment
that only the search used.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant