Skip to content

Commit

Permalink
Enhance error message for missing struct properties and update README…
Browse files Browse the repository at this point in the history
… with installation instructions for Go and VSCode extension
  • Loading branch information
itsfuad committed Dec 5, 2024
1 parent 52aac7e commit b82de1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions analyzer/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ func checkStructLiteral(structLit ast.StructLiteral, env *TypeEnvironment) TcVal
continue
}
if _, ok := structLit.Properties[propname]; !ok {
structName := tcValueToString(structType)
errgen.AddError(env.filePath, structLit.StartPos().Line, structLit.EndPos().Line, structLit.StartPos().Column, structLit.EndPos().Column, fmt.Sprintf("property '%s' is missing on struct '%s'", propname, structName), errgen.ERROR_NORMAL)
errgen.AddError(env.filePath, structLit.StartPos().Line, structLit.EndPos().Line, structLit.StartPos().Column, structLit.EndPos().Column, fmt.Sprintf("property '%s' is missing on @%s", propname, sName.Name), errgen.ERROR_NORMAL)
}
}

Expand Down
10 changes: 10 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ A tiny simple programming language made for simplicity. It borrows syntax from '
- [ ] Codegen

[Runnning the compiler](#running-the-compiler)
[Install Go](#install-go)
[Running the tests](#running-the-tests)
[Installing syntax highlighting for vscode](#installing-syntax-highlighting-for-vscode)
[Build the extension](#build-the-extension)
[Install from marketplace](#install-from-marketplace)


# Example
Expand Down Expand Up @@ -343,6 +346,11 @@ fn printPerson(p: Printable) {
```

# Running the compiler

## Install Go
To run the compiler, you need to have go installed. You can download it from [here](https://golang.org/dl/)

## Testing a walrus file
To test a walrus file, you need to open `main.go` and change the `filePath` variable to the path of the file you want to test.
```go
func main() {
Expand Down Expand Up @@ -375,6 +383,7 @@ To install local build, go to `language-support` directory and run the following
```sh
npm install -g vsce
```
## Build the extension
If you don't have node installed, you can download it from [here](https://nodejs.org/en/download/)
Then run the following command
```sh
Expand All @@ -383,5 +392,6 @@ code --install-extension walrus-<full-output-name>.vsix
```
Or open vscode, go to extensions and click on the three dots on the top right corner and click on 'Install from VSIX' and select the generated vsix file.

## Install from marketplace
Or, you can install the extension from the marketplace [here](https://marketplace.visualstudio.com/items?itemName=Walrus.walrus)
Or, Search for 'Walrus' in the vscode extensions marketplace.

0 comments on commit b82de1b

Please sign in to comment.