question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing validation when casting an argument

See original GitHub issue

Environment

Name Version
IDEA version 2021
Luanalysis version 1.3.0
OS macOS 11.5

What are the steps to reproduce this issue?

---@shape shapeA
---@field fieldA string

local variableA = "A"
local function receiveAny(_any)
    
end
receiveAny(--[[---@type number]] "")
receiveAny(--[[---@type number]] {})
receiveAny(--[[---@type number]] variableA)
receiveAny(--[[---@type shapeA]] variableA)

What happens?

None of the arguments in the receiveAny executions are validated, everything is accepted.

What were you expecting to happen?

All of the receiveAny executions should fail.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pouwelsjochemcommented, Sep 14, 2021

Thanks! I was aware of the .def.lua files indeed, used them to map out the parts of the Solar2D engine I use ^^ However I’m not a fan of adding game-specific shapes to that definition file, hence I’m more in favour of writing a wrapper 😃

0reactions
Benjamin-Dobellcommented, Sep 14, 2021

Assuming the external library doesn’t already have types, you can provide your own types for the library. Here’s an example for Tabletop Simulator:

https://github.com/Benjamin-Dobell/tts-types/tree/master/tts

Those .def.lua files provide Lua definitions for functions/tables/userdata which are (mostly) implemented in C#. However, the same process ought to work for regular Lua libraries. Basically anywhere in your IntelliJ project you can provide a <module name>.def.lua file that provides types. The only thing special about the .def.lua extension is that irrelevant inspections are disabled.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Argument provided to Rails validate function is sometimes ...
When running certain tests, I would get a validation failure as expected. However, the error is not a RecordInvalid ; instead, it's an ......
Read more >
Missing type validation for lists · Issue #2428 - GitHub
I have a resolver that takes a list of enums as an argument, but when i send something other than that enum ir...
Read more >
Request Handling — Connexion 2.0 documentation
Request Validation​​ Both the request body and parameters are validated against the specification, using jsonschema. If the request doesn't match the ...
Read more >
Verifying the user's response | reCAPTCHA | Google Developers
This page explains how to verify a user's response to a reCAPTCHA challenge from your application's backend. For web users, you can get...
Read more >
Validation - Laravel - The PHP Framework For Web Artisans
The first argument passed to the make method is the data under validation. The second argument is an array of the validation rules...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found