Skip to content

fix: make format parameter optional in os.date function - #1093

Merged
CppCXY merged 1 commit into
EmmyLuaLs:mainfrom
tinyleolin:enhance-os-date-annotations
May 25, 2026
Merged

CppCXY merged 1 commit into
EmmyLuaLs:mainfrom
tinyleolin:enhance-os-date-annotations

Conversation

@tinyleolin

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions

Copy link
Copy Markdown

Code Review Summary

File: crates/emmylua_code_analysis/resources/std/os.lua

Change: Line 81 - @param format string → @param format? string

✅ Issue Identified: Incorrect Parameter Type Annotation

Problem: The original annotation @param format string incorrectly marks the format parameter as required, when in Lua's os.date() function it is actually optional.

Evidence:

  • The Lua 5.1/5.2/5.3 reference manual states that os.date([format [, time]]) has both parameters as optional
  • When called without arguments, os.date() returns the current date/time as a string using the default format
  • The existing @overload annotations already demonstrate optional usage patterns

Recommendation: The change from @param format string to @param format? string is correct and should be approved. This fix:

  • Aligns the type annotation with actual Lua language specification
  • Matches the existing overload signatures that show optional usage
  • Improves code analysis accuracy for downstream tools

Additional Observations

  1. Consistency Check: The time parameter is already correctly annotated as @param time? number (optional), so this change makes the format parameter consistent.

  2. No Other Issues Found: The change is minimal, focused, and addresses a clear documentation/annotation error without introducing any new problems.

Final Verdict

APPROVED - This is a straightforward, correct fix that improves the accuracy of the type annotations for Lua's os.date() function.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Lua standard library definition for the os.date function in crates/emmylua_code_analysis/resources/std/os.lua, marking the format parameter as optional to accurately reflect its usage. No review comments were provided for this change, so I have no additional feedback to offer.

@CppCXY
CppCXY merged commit ff13e9e into EmmyLuaLs:main May 25, 2026
17 checks passed
@tinyleolin
tinyleolin deleted the enhance-os-date-annotations branch May 25, 2026 15:07
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
emmylua_ls 0.23.2

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What's Changed
* fix: make code actions follow formatter tag spacing by @lewis6991 in EmmyLuaLs/emmylua-analyzer-rust#1089
* fix: make format parameter optional in os.date function by @tinyleolin in EmmyLuaLs/emmylua-analyzer-rust#1093
* perf: avoid unrelated multi-return correlation by @lewis6991 in EmmyLuaLs/emmylua-analyzer-rust#1095
* fix: handle semantic flow edge cases by @lewis6991 in EmmyLuaLs/emmylua-analyzer-rust#1086
* fix: avoid recursive signature instantiation by @lewis6991 in EmmyLuaLs/emmylua-analyzer-rust#1085


**Full Changelog**: https://github.com/EmmyLuaLs/emmylua-analyzer-rust/compare/0.23.1...0.23.2</pre>
  <p>View the full release notes at <a href="https://github.com/EmmyLuaLs/emmylua-analyzer-rust/releases/tag/0.23.2">https://github.com/EmmyLuaLs/emmylua-analyzer-rust/releases/tag/0.23.2</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!10353
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.

2 participants