{"id":18866054,"url":"https://github.com/adia-dev/zlg_bug_hover","last_synced_at":"2025-10-29T23:50:50.078Z","repository":{"id":222013705,"uuid":"755916546","full_name":"adia-dev/zlg_bug_hover","owner":"adia-dev","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-11T13:29:03.000Z","size":396,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-18T06:47:09.570Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adia-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-11T13:29:00.000Z","updated_at":"2024-02-11T17:40:49.000Z","dependencies_parsed_at":"2024-02-11T20:15:13.395Z","dependency_job_id":"64b8fc94-a575-4005-8882-0f95fc8323b0","html_url":"https://github.com/adia-dev/zlg_bug_hover","commit_stats":null,"previous_names":["adia-dev/zlg_bug_hover"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adia-dev%2Fzlg_bug_hover","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adia-dev%2Fzlg_bug_hover/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adia-dev%2Fzlg_bug_hover/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adia-dev%2Fzlg_bug_hover/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adia-dev","download_url":"https://codeload.github.com/adia-dev/zlg_bug_hover/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239810095,"owners_count":19700737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T05:05:24.772Z","updated_at":"2025-10-29T23:50:45.009Z","avatar_url":"https://github.com/adia-dev.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZLS Hover Information Bug Reproduction\n\n## Overview\n\nThis repository contains a minimal Zig code example that demonstrates an issue with Zig Language Server (ZLS) providing incorrect type information on hover for a specific case involving union downcasting.\n\nThe bug has been spotted on zig version `0.12.0-dev.2500+c085c6ecd` and zls version `0.12.0-dev.365+a8a83b6`.\n\n## Issue Description\n\nIn the provided Zig code, when attempting to downcast from `UnaryExpression.Right` to `NumberLiteralExpression`, the expected type on hover should be `*NumberLiteralExpression`. However, ZLS incorrectly displays it as `*UnaryExpression`.\n\nSee image below:\n![Screenshot of the hover event](./images/hover.png)\n\nAs shown in the screenshot above, the hover information incorrectly indicates the type as `*UnaryExpression` instead of `*NumberLiteralExpression`.\n\n## Steps to Reproduce\n\n1. Clone this repository.\n2. Open the project in your preferred Zig development environment that utilizes ZLS.\n3. Hover over the variable `number` in the `main` function to observe the type information provided by ZLS.\n4. You can execute the code to see that zig is evaluating the downcast accordingly.\n\n## Expected Behavior\n\nThe hover information for `number` should indicate its type as `*NumberLiteralExpression`.\n\n## Actual Behavior\n\nThe hover information for `number` incorrectly indicates its type as `*UnaryExpression`.\n\n## Environment\n\n- Zig version: 0.12.0-dev.2500+c085c6ecd\n- ZLS version: 0.12.0-dev.365+a8a83b6\n- OS: MacOS M1 Pro 2020 Sonoma 14.2.1\n\n## Code Snippet\n\n```zig\n// ✅ Downcast from Statement to ExpressionStatement\nif (statement.downcast(ExpressionStatement)) |expr_stmt| {\n    // ✅ Downcast from ExpressionStatement.Expression to UnaryExpression\n    if (expr_stmt.expression.downcast(UnaryExpression)) |unary| {\n        // ❌ Downcast from UnaryExpression.Right to NumberLiteralExpression\n        if (unary.right.downcast(NumberLiteralExpression)) |number| {\n            std.debug.print(\"I am a NumberLiteralExpression and not a UnaryExpression: {}\\n\", .{number});\n        }\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadia-dev%2Fzlg_bug_hover","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadia-dev%2Fzlg_bug_hover","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadia-dev%2Fzlg_bug_hover/lists"}