Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vim9] "Cannot index a special variable" when applying += to class member #11820

Closed
lifepillar opened this issue Jan 14, 2023 · 0 comments
Closed
Labels

Comments

@lifepillar
Copy link
Contributor

Steps to reproduce

Source this script:

vim9script

class Foo
  this.x: number

  def Add(n: number)
    this.x += n
  enddef
endclass

var f =  Foo.new(1)
f.Add(41)
echo f.x

This results in E909: Cannot index a special variable. A workaround consists in changing the assignment inside Add() into this.x = this.x + n.

Expected behaviour

No error should be raised and the output should be 42.

Version of Vim

9.0.1198

Environment

macOS 13.1
Apple Terminal
xterm-256color
ZSH 5.8.1

Logs and stack traces

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant