Skip to content

Support LuaJIT syntax extensions #1040

@ligurio

Description

@ligurio

LuaJIT has extensions to the Lua Parser, see 1

sample.lua:

-- Decimal literals.
local a = 100000005LL
local b = 100000005ULL

-- Hexadecimal literals.
local c = 0x100000005LL
local d = 0x100000005ULL

-- Binary literals.
local e = 0b101010LL
local f = 0b101010ULL

-- Complex numbers.
local g = 12.5i
local h = 12.5I
local i = 1i
local j = 1I
$ luajit sample.lua; echo $?
0

An output of emmulua_check sample.lua:

---  [20 errors, 9 hints]
error: unexpected character 'L' after number literal [syntax-error]
  --> :2:11

  1 | -- Decimal literals.
  2 | local a = 100000005LL
  3 | local b = 100000005ULL

error: unexpected character 'U' after number literal [syntax-error]
  --> :3:11

  2 | local a = 100000005LL
  3 | local b = 100000005ULL
  4 | 

error: unexpected character 'L' after number literal [syntax-error]
  --> :6:11

  5 | -- Hexadecimal literals.
  6 | local c = 0x100000005LL
  7 | local d = 0x100000005ULL

error: unexpected character 'U' after number literal [syntax-error]
  --> :7:11

  6 | local c = 0x100000005LL
  7 | local d = 0x100000005ULL
  8 | 

error: unexpected character 'b' after number literal [syntax-error]
  --> :10:11

   9 | -- Binary literals.
  10 | local e = 0b101010LL
  11 | local f = 0b101010ULL

error: unexpected character 'b' after number literal [syntax-error]
  --> :11:11

  10 | local e = 0b101010LL
  11 | local f = 0b101010ULL
  12 | 

error: unexpected character 'i' after number literal [syntax-error]
  --> :14:11

  13 | -- Complex numbers.
  14 | local g = 12.5i
  15 | local h = 12.5I

error: unexpected character 'I' after number literal [syntax-error]
  --> :15:11

  14 | local g = 12.5i
  15 | local h = 12.5I
  16 | local i = 1i

error: unexpected character 'i' after number literal [syntax-error]
  --> :16:11

  15 | local h = 12.5I
  16 | local i = 1i
  17 | local j = 1I

error: unexpected character 'I' after number literal [syntax-error]
  --> :17:11

  16 | local i = 1i
  17 | local j = 1I

error: expected '=' for assignment or this is an incomplete statement [syntax-error]
  --> :3:1

  2 | local a = 100000005LL
  3 | local b = 100000005ULL
  4 | 

error: expected '=' for assignment or this is an incomplete statement [syntax-error]
  --> :6:1

  5 | -- Hexadecimal literals.
  6 | local c = 0x100000005LL
  7 | local d = 0x100000005ULL

error: expected '=' for assignment or this is an incomplete statement [syntax-error]
  --> :7:1

  6 | local c = 0x100000005LL
  7 | local d = 0x100000005ULL
  8 | 

error: expected '=' for assignment or this is an incomplete statement [syntax-error]
  --> :10:1

   9 | -- Binary literals.
  10 | local e = 0b101010LL
  11 | local f = 0b101010ULL

error: expected '=' for assignment or this is an incomplete statement [syntax-error]
  --> :11:1

  10 | local e = 0b101010LL
  11 | local f = 0b101010ULL
  12 | 

error: expected '=' for assignment or this is an incomplete statement [syntax-error]
  --> :14:1

  13 | -- Complex numbers.
  14 | local g = 12.5i
  15 | local h = 12.5I

error: expected '=' for assignment or this is an incomplete statement [syntax-error]
  --> :15:1

  14 | local g = 12.5i
  15 | local h = 12.5I
  16 | local i = 1i

error: expected '=' for assignment or this is an incomplete statement [syntax-error]
  --> :16:1

  15 | local h = 12.5I
  16 | local i = 1i
  17 | local j = 1I

error: expected '=' for assignment or this is an incomplete statement [syntax-error]
  --> :17:1

  16 | local i = 1i
  17 | local j = 1I

error: expected '=' for assignment or this is an incomplete statement [syntax-error]
  --> :17:13

  16 | local i = 1i
  17 | local j = 1I

hint: j is never used, if this is intentional, prefix it with an underscore: _j [unused]
  --> :17:7

  16 | local i = 1i
  17 | local j = 1I

hint: d is never used, if this is intentional, prefix it with an underscore: _d [unused]
  --> :7:7

  6 | local c = 0x100000005LL
  7 | local d = 0x100000005ULL
  8 | 

hint: f is never used, if this is intentional, prefix it with an underscore: _f [unused]
  --> :11:7

  10 | local e = 0b101010LL
  11 | local f = 0b101010ULL
  12 | 

hint: b is never used, if this is intentional, prefix it with an underscore: _b [unused]
  --> :3:7

  2 | local a = 100000005LL
  3 | local b = 100000005ULL
  4 | 

hint: c is never used, if this is intentional, prefix it with an underscore: _c [unused]
  --> :6:7

  5 | -- Hexadecimal literals.
  6 | local c = 0x100000005LL
  7 | local d = 0x100000005ULL

hint: g is never used, if this is intentional, prefix it with an underscore: _g [unused]
  --> :14:7

  13 | -- Complex numbers.
  14 | local g = 12.5i
  15 | local h = 12.5I

hint: h is never used, if this is intentional, prefix it with an underscore: _h [unused]
  --> :15:7

  14 | local g = 12.5i
  15 | local h = 12.5I
  16 | local i = 1i

hint: a is never used, if this is intentional, prefix it with an underscore: _a [unused]
  --> :2:7

  1 | -- Decimal literals.
  2 | local a = 100000005LL
  3 | local b = 100000005ULL

hint: e is never used, if this is intentional, prefix it with an underscore: _e [unused]
  --> :10:7

   9 | -- Binary literals.
  10 | local e = 0b101010LL
  11 | local f = 0b101010ULL



Summary
  20 errors
  9 hints

Check failed

emmylua_check 0.22.0

Footnotes

  1. https://luajit.org/ext_ffi_api.html#literals

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions