LuaLS / LuaLS/lua-language-server

Feature request: Opaque/nominal types

Open
#2,074 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

The problem

It often happens that library functions return objects the type of which is an implementation detail. For example an identifier may be an integer but could suddenly be changed to a string, and the client code shouldn't fail because of that.

Safely typing such an identifier in LLS is currently impossible:

  • typing it as integer depends on a potentially unstable implementation detail
  • typing it as any is unsound

In other words, structural typing fails when the structure isn't stable or known.

Feature request

An annotations that declares a completely opaque/nominal type. It could be --@opaque typename, --@alias typename without any arguments, or anything else. Values belonging of such a type cannot be inspected in any way and can only be passed around. Values of different opaque types cannot be mixed up (so this is stronger than unknown in typescript)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by locating the annotation and type-checking code for aliases and unknown types, then trace how values are inspected or mixed. Done means the language server supports distinct opaque types that can only be passed around, with coverage for the requested behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.