jonnyboyC / kos-language-server

A language server for the Kerboscript (kOS) a language for Kerbal Space Program
MIT License
25 stars 6 forks source link

Explicity check if type has setter / getter. #127

Closed jonnyboyC closed 4 years ago

jonnyboyC commented 4 years ago
local x is ship:body:patches:sublist(0, 10):join(",")[10].
//          ^     ^      ^       ^            ^        ^
//          \-----|------|-------|------------|--------|--- Look type using symbol table to get tracker
//                \------|-------|------------|--------|--- Check for "body" suffix on type "vesselTarget" return suffix "getter"
//                       \-------|------------|--------|--- Get assignment type of "body" check for "patches" on "bodyTarget" return suffix "getter"
//                               \------------|--------|--- Get assignment type of "patches" check for "sublist" on "vector" return suffix "method"
//                                            \--------|--- Get assignment type of "sublist" check for "join" on "vector" return suffix "method"
//                                                     \ --- Get assignment type of "join" check if indexer exists and return
//
// during assignment we get assignment type of the final indexer and assign to x

The internal nodes of an expression now individual check for getter, until the final node in the example the indexer. In the statement we then check the resulting expression has the correct access or call signature needed.