-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Labels
Description
Steps to reproduce
(Before the failing class examples, I have included a couple
of working class examples named TestPassing*.)
Example 1:
vim9script
class TestPassing1
const one: number = TestPassing1.One(this)
static def One(that: TestPassing1): number
return 1
enddef
endclass
echo TestPassing1.One(TestPassing1.new())
class TestPassing2
const one: number = 1
const two: number = TestPassing2.Two(this)
static def Two(that: TestPassing2): number
return that.one + 1
enddef
endclass
echo TestPassing2.Two(TestPassing2.new())
class Test2
const two: number = Test2.Two(this)
const one: number = 1
static def Two(that: Test2): number
return that.one + 2
enddef
endclass
# E340
echo Test2.Two(Test2.new())
Example 2:
vim9script
class TestPassing1
const Id: func(any): any = ((_) => (v) => v)(this)
static def Id(that: TestPassing1): func(any): any
return that.Id
enddef
endclass
echo TestPassing1.Id(TestPassing1.new())(1)
echo TestPassing1.new().Id(1)
class Test1
const Id: func(any): any = ((that) => (_) => that)(this)
static def Id(that: Test1): func(any): any
return that.Id
enddef
endclass
# E340
const Id0: func(any): any = Test1.Id(Test1.new())
# E340
const Id1: func(any): any = Test1.new().Id
class Test2
const Id: any = Test2.Id(this)
static def Id(that: Test2): any
return that.Id
enddef
endclass
# E340
const Id2: any = Test2.Id(Test2.new())
# E340
const Id3: any = Test2.new().Id
Expected behaviour
Each failure can probably be justified on the grounds of
interfering with step 2.
Lines 259 to 263 in 3fa8f77
| The sequence of constructing a new object is: | |
| 1. Memory is allocated and cleared. All values are zero/false/empty. | |
| 2. For each declared object variable that has an initializer, the expression | |
| is evaluated and assigned to the variable. This happens in the sequence | |
| the variables are declared in the class. |
Do we need a dedicated EXXX for an inappropriate state?
Version of Vim
v9.1.0263
Environment
GNU/Linux Debian (testing/trixie)
Logs and stack traces
No response