René's URL Explorer Experiment


Title: Error object returned by pcall() declared to always be a string · Issue #79 · TypeScriptToLua/lua-types · GitHub

Open Graph Title: Error object returned by pcall() declared to always be a string · Issue #79 · TypeScriptToLua/lua-types

X Title: Error object returned by pcall() declared to always be a string · Issue #79 · TypeScriptToLua/lua-types

Description: Description pcall() is declared to return LuaMultiReturn<[true, R] | [false, string]>, but in Lua, the error object can be anything. This leads to problem when the error object is used in a context where it matters whether it can be some...

Open Graph Description: Description pcall() is declared to return LuaMultiReturn<[true, R] | [false, string]>, but in Lua, the error object can be anything. This leads to problem when the error object is used in a context...

X Description: Description pcall() is declared to return LuaMultiReturn<[true, R] | [false, string]>, but in Lua, the error object can be anything. This leads to problem when the error object is used in a c...

Opengraph URL: https://github.com/TypeScriptToLua/lua-types/issues/79

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error object returned by pcall() declared to always be a string","articleBody":"#### Description\r\n\r\n`pcall()` is [declared](https://github.com/TypeScriptToLua/lua-types/blob/master/core/global.d.ts#L180) to return `LuaMultiReturn\u003c[true, R] | [false, string]\u003e`, but in Lua, the error object can be anything. This leads to problem when the error object is used in a context where it matters whether it can be something other than a string.\r\n\r\n#### To reproduce\r\n\r\nConsider the following example ([playground](https://typescripttolua.github.io/play/#code/GYVwdgxgLglg9mABMOcAUUAWMDOAuRANzhgBMBKRAbwChF7EsAnOAd2oF8auaAbAUyiIm-HCF5CAvIgAOEAIa9eaFHHI0aMYIjQBCEWIkBtAAwBdSrQaymMMFDQAifkxZMCjxAGpho8VCMARgtuGiA)):\r\n\r\n```typescript\r\nfunction foo(this: void) {\r\n    throw {}\r\n}\r\n\r\nlet result = pcall(foo)\r\n\r\nif (!result[0]) {\r\n    print(\"error: \" + result[1])\r\n}\r\n```\r\n\r\nFunction `foo()` throws an empty object. To allow concatenation with a string, a call to `tostring()` needs to be inserted, but it isn't. So the concatenation in the argument to `print()` fails:\r\n\r\n```\r\nLua execution error:\r\n\t[string \"--[[ Generated with https://github.com/TypeSc...\"]:7: attempt to concatenate a table value (field '?')\r\n```\r\n\r\nIf the correct type is added to the declaration of `result`, the call to `tostring()` is inserted:\r\n\r\n```typescript\r\nlet result: [true, void] | [false, unknown] = pcall(foo)\r\n```\r\n\r\nGenerated code:\r\n\r\n```lua\r\n--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]\r\nfunction foo()\r\n    error({}, 0)\r\nend\r\nresult = {pcall(foo)}\r\nif not result[1] then\r\n    print(\"error: \" .. tostring(result[2]))\r\nend\r\n```\r\n\r\n#### Expected behavior\r\n\r\nI think that the return type of `pcall()` should be changed to `LuaMultiReturn\u003c[true, R] | [false, unknown]\u003e`. The same applies to [`coroutine.resume()`](https://github.com/TypeScriptToLua/lua-types/blob/b224030d184a233c8b2eba021b04f07987b631be/core/coroutine.d.ts#L28).","author":{"url":"https://github.com/Feuermurmel","@type":"Person","name":"Feuermurmel"},"datePublished":"2024-11-06T13:17:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/79/lua-types/issues/79"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:df339719-5e7d-218e-65d8-37eb8775c3fc
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBAEA:1D94B1:1E7B41:29F8F5:69720E81
html-safe-nonce16127821b8b1b6ff62505f32d0a0ebcbf8433db70c0aede1efbb8740a56ac614
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQUVBOjFEOTRCMToxRTdCNDE6MjlGOEY1OjY5NzIwRTgxIiwidmlzaXRvcl9pZCI6IjEwNzU4NzA2ODY0Mzg4ODcwNDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac499cea8a1542a3bff1a16e66267a9f48d45405f02e8fe29a10ac13e5c250b8ba
hovercard-subject-tagissue:2638076681
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/TypeScriptToLua/lua-types/79/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3d0f01191d66ba7d16a698df8dd08e539c26b4cc435a414c7dc82a230ca3f2e5/TypeScriptToLua/lua-types/issues/79
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3d0f01191d66ba7d16a698df8dd08e539c26b4cc435a414c7dc82a230ca3f2e5/TypeScriptToLua/lua-types/issues/79
og:image:altDescription pcall() is declared to return LuaMultiReturn<[true, R] | [false, string]>, but in Lua, the error object can be anything. This leads to problem when the error object is used in a context...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameFeuermurmel
hostnamegithub.com
expected-hostnamegithub.com
None453de246939b1e04d711e109432e2df10933270413df93b7a8f8f1df8dda7f18
turbo-cache-controlno-preview
go-importgithub.com/TypeScriptToLua/lua-types git https://github.com/TypeScriptToLua/lua-types.git
octolytics-dimension-user_id44121206
octolytics-dimension-user_loginTypeScriptToLua
octolytics-dimension-repository_id116213653
octolytics-dimension-repository_nwoTypeScriptToLua/lua-types
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id116213653
octolytics-dimension-repository_network_root_nwoTypeScriptToLua/lua-types
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release12756e5bdb9000be815bbf20a1acc7935638e596
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/TypeScriptToLua/lua-types/issues/79#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FTypeScriptToLua%2Flua-types%2Fissues%2F79
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FTypeScriptToLua%2Flua-types%2Fissues%2F79
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=TypeScriptToLua%2Flua-types
Reloadhttps://github.com/TypeScriptToLua/lua-types/issues/79
Reloadhttps://github.com/TypeScriptToLua/lua-types/issues/79
Reloadhttps://github.com/TypeScriptToLua/lua-types/issues/79
TypeScriptToLua https://github.com/TypeScriptToLua
lua-typeshttps://github.com/TypeScriptToLua/lua-types
Notifications https://github.com/login?return_to=%2FTypeScriptToLua%2Flua-types
Fork 15 https://github.com/login?return_to=%2FTypeScriptToLua%2Flua-types
Star 82 https://github.com/login?return_to=%2FTypeScriptToLua%2Flua-types
Code https://github.com/TypeScriptToLua/lua-types
Issues 3 https://github.com/TypeScriptToLua/lua-types/issues
Pull requests 4 https://github.com/TypeScriptToLua/lua-types/pulls
Actions https://github.com/TypeScriptToLua/lua-types/actions
Projects 0 https://github.com/TypeScriptToLua/lua-types/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/TypeScriptToLua/lua-types/security
Please reload this pagehttps://github.com/TypeScriptToLua/lua-types/issues/79
Insights https://github.com/TypeScriptToLua/lua-types/pulse
Code https://github.com/TypeScriptToLua/lua-types
Issues https://github.com/TypeScriptToLua/lua-types/issues
Pull requests https://github.com/TypeScriptToLua/lua-types/pulls
Actions https://github.com/TypeScriptToLua/lua-types/actions
Projects https://github.com/TypeScriptToLua/lua-types/projects
Security https://github.com/TypeScriptToLua/lua-types/security
Insights https://github.com/TypeScriptToLua/lua-types/pulse
New issuehttps://github.com/login?return_to=https://github.com/TypeScriptToLua/lua-types/issues/79
New issuehttps://github.com/login?return_to=https://github.com/TypeScriptToLua/lua-types/issues/79
Error object returned by pcall() declared to always be a stringhttps://github.com/TypeScriptToLua/lua-types/issues/79#top
https://github.com/Feuermurmel
https://github.com/Feuermurmel
Feuermurmelhttps://github.com/Feuermurmel
on Nov 6, 2024https://github.com/TypeScriptToLua/lua-types/issues/79#issue-2638076681
declaredhttps://github.com/TypeScriptToLua/lua-types/blob/master/core/global.d.ts#L180
playgroundhttps://typescripttolua.github.io/play/#code/GYVwdgxgLglg9mABMOcAUUAWMDOAuRANzhgBMBKRAbwChF7EsAnOAd2oF8auaAbAUyiIm-HCF5CAvIgAOEAIa9eaFHHI0aMYIjQBCEWIkBtAAwBdSrQaymMMFDQAifkxZMCjxAGpho8VCMARgtuGiA
coroutine.resume()https://github.com/TypeScriptToLua/lua-types/blob/b224030d184a233c8b2eba021b04f07987b631be/core/coroutine.d.ts#L28
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.