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

fix: make format parameter optional in os.date function#1093
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.

Copy link
Copy Markdown
Contributor

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

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