Title: Vim9: crash when script-level loop variable changes type inside a closure · Issue #22012 · vim/vim · GitHub
Open Graph Title: Vim9: crash when script-level loop variable changes type inside a closure · Issue #22012 · vim/vim
X Title: Vim9: crash when script-level loop variable changes type inside a closure · Issue #22012 · vim/vim
Description: Steps to reproduce Sourcing the following script crashes Vim: vim9script for y in [10, 'b'] var Add = (): any => y * 2 echomsg Add() endfor Expected behaviour "20", then an error for multiplying a String: E1030: Using a String as a Numbe...
Open Graph Description: Steps to reproduce Sourcing the following script crashes Vim: vim9script for y in [10, 'b'] var Add = (): any => y * 2 echomsg Add() endfor Expected behaviour "20", then an error for multiplying a ...
X Description: Steps to reproduce Sourcing the following script crashes Vim: vim9script for y in [10, 'b'] var Add = (): any => y * 2 echomsg Add() endfor Expected behaviour "20", then an err...
Opengraph URL: https://github.com/vim/vim/issues/22012
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Vim9: crash when script-level loop variable changes type inside a closure","articleBody":"### Steps to reproduce\n\nSourcing the following script crashes Vim:\n\n```vim\nvim9script\nfor y in [10, 'b']\n var Add = (): any => y * 2\n echomsg Add()\nendfor\n```\n\n### Expected behaviour\n\n\"20\", then an error for multiplying a String: `E1030: Using a String as a Number: \"b\"`, as in a def function.\n\n### Version of Vim\n\n9.2.1355\n\n### Environment\n\nLinux\n","author":{"url":"https://github.com/yegappan","@type":"Person","name":"yegappan"},"datePublished":"2026-11-23T02:20:16Z","url":"https://github.com/vim/vim/issues/22012"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cd79c259-f8ea-4fd7-bd0d-1b5146e0cc57 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE3E:214D3B:29B53:381DB:6B0745CF |
| html-safe-nonce | fafb5b8fb63479e27537d10ac828ec05d044f5abd5a86a262d5edea8b45a8265 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTNFOjIxNEQzQjoyOUI1MzozODFEQjo2QjA3NDVDRiIsInZpc2l0b3JfaWQiOiIzMjE1NzUyMDg3NzMyNzAwNjIzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f84a9caacd7728a45abb2cdb189278c63173363c2501f57a33613253adfa9dfc |
| hovercard-subject-tag | issue:6550932471 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/vim/vim/22012/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ada6578e2fa8c24ace24228cbe87084ac4e21bb6511391185f39ad20803a8267/vim/vim/issues/22012 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ada6578e2fa8c24ace24228cbe87084ac4e21bb6511391185f39ad20803a8267/vim/vim/issues/22012 |
| og:image:alt | Steps to reproduce Sourcing the following script crashes Vim: vim9script for y in [10, 'b'] var Add = (): any => y * 2 echomsg Add() endfor Expected behaviour "20", then an error for multiplying a ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yegappan |
| hostname | github.com |
| expected-hostname | github.com |
| None | e906c59266d83416af9bcc8b61b9a96e70a3a84a066bd24f6671c193dd134a04 |
| turbo-cache-control | no-preview |
| go-import | github.com/vim/vim git https://github.com/vim/vim.git |
| octolytics-dimension-user_id | 11618545 |
| octolytics-dimension-user_login | vim |
| octolytics-dimension-repository_id | 40997482 |
| octolytics-dimension-repository_nwo | vim/vim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 40997482 |
| octolytics-dimension-repository_network_root_nwo | vim/vim |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a8418b8cd1f6ecc99bee02e3f7dde540702dd08c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width