Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

string|nil passed to string parameter not flagged as error with strict settings

Đang mở
#3,226 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
lua
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu với trình tái hiện Lua được cung cấp và .luarc.json, sau đó chạy lệnh lua-language-server --check được ghi trong tài liệu để xác nhận chẩn đoán còn thiếu. Theo dõi đường đi kiểm tra kiểu cho các đối số hàm và thêm độ bao phủ hồi quy; công việc được hoàn tất khi đối số string|nil được báo cáo là không tương thích với tham số string bắt buộc.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

How are you using the lua-language-server?

Command Line

Which OS are you using?

Linux

What is the issue affecting?

Type Checking

Expected Behaviour

With the following config (see below), I expect Lua Language Server to report a type mismatch when passing a string|nil value to a function that expects a non-optional string parameter.

Specifically, this line should raise a diagnostic:

test_func(params.ip) -- where params.ip is string|nil, but test_func expects string
Actual Behaviour

No error is reported by LLS, neither in VS Code nor when using the CLI with --check.

Reproduction steps
  1. Save this code in a .lua file:
---@class TestParams
---@field ip string | nil

---@param ip string
---@return string
local function test_func(ip)
    return ip
end

---@type TestParams
local params = { ip = nil }

test_func(params.ip)

  1. Use the following lua-language-server config (.luarc.json or through your client):
{
  "runtime": {
    "version": "Lua 5.1"
  },
  "diagnostics": {
    "enable": true,
    "disable": [],
    "groupFileStatus": {
      "ambiguity": "Any",
      "await": "Any",
      "codestyle": "Any",
      "duplicate": "Any",
      "global": "Any",
      "luadoc": "Any",
      "redefined": "Any",
      "strict": "Any",
      "strong": "Any",
      "type-check": "Any",
      "unbalanced": "Any",
      "unused": "Any"
    },
    "groupSeverity": {
      "ambiguity": "Error",
      "await": "Error",
      "codestyle": "Error",
      "duplicate": "Error",
      "global": "Error",
      "luadoc": "Error",
      "redefined": "Error",
      "strict": "Error",
      "strong": "Error",
      "type-check": "Error",
      "unbalanced": "Error",
      "unused": "Error"
    }
  },
  "type": {
    "weakNilCheck": false
  }
}
  1. Run the CLI:
lua-language-server-3.15.0-linux-x64/bin/lua-language-server --check your_file.lua

Or use VS Code extension.

Additional Notes

No response

Log File
Diagnosis completed, no problems found
Ngôn ngữ chính
Lua
Star
4.4k
Fork
442
Merge trung bình
8 ngày 9 giờ
Pull request đã merge (30 ngày)
1

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của LuaLS/lua-language-server

Tất cả issue của LuaLS/lua-language-server

Issue tương tự

Thêm issue về Lua

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.