Skip to content

Commit

Permalink
Update lint.md
Browse files Browse the repository at this point in the history
Document new additions to integer parsing lint
  • Loading branch information
zeux committed Nov 6, 2023
1 parent 8dc1550 commit b32ca49
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions _pages/lint.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
![image](https://github.com/luau-lang/site/assets/1106629/36b477a4-0742-47dc-94ef-6dfe633ed6f6)---
permalink: /lint
title: Linting
toc: true
Expand Down Expand Up @@ -340,10 +340,17 @@ Luau uses comments that start from `!` to control certain aspects of analysis, f
Luau parses hexadecimal and binary literals as 64-bit integers before converting them to Luau numbers. As a result, numbers that exceed 2^64 are silently truncated to 2^64, which can result in unexpected program behavior. This warning flags literals that are truncated:

```lua
-- Hexadecimal number literal exceeded available precision and has been truncated to 2^64
-- Hexadecimal number literal exceeded available precision and was truncated to 2^64
local x = 0x1111111111111111111111111111111111111
```

Luau numbers are represented as double precision IEEE754 floating point numbers; they can represent integers up to 2^53 exactly, but larger integers may lose precision. This warning also flags literals that are parsed with a precision loss:

```lua
-- Number literal exceeded available precision and was truncated to closest representable number
local x = 9007199254740993
```

## ComparisonPrecedence (28)

Because of operator precedence rules, not X == Y parses as (not X) == Y; however, often the intent was to invert the result of the comparison. This warning flags erroneous conditions like that, as well as flagging cases where two comparisons happen in a row without any parentheses:
Expand Down

0 comments on commit b32ca49

Please sign in to comment.