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

inconsistent result of var declarations #289

Closed
Tracked by #277
x87 opened this issue Nov 10, 2023 · 3 comments
Closed
Tracked by #277

inconsistent result of var declarations #289

x87 opened this issue Nov 10, 2023 · 3 comments
Labels
priority:p2 Medium priority scope:compiler type:bug Something isn't working
Milestone

Comments

@x87
Copy link
Collaborator

x87 commented Nov 10, 2023

there are two main ways of declaring a variable type:

  1. using var keyword. var 0@: int, var $var: int
  2. using a predefined type followed by variable name: int a, int 0@, int $var

For local variables (@) and global variables ($, &) the end result is the same regardless of the chosen syntax.

For identifiers the results are different.

int a acts similarly to const a = 0@
var a: int yields no error, but does not create a new variable either. var a: int = 100 produces an error

declaring another constant with the same name shadows the variable declaration:

const a = $100

int a
a = 1 // expected local var 0@, got $100
const a = $100
var a: int = 100 // compiles as $100 = 0

Expectation

const a = $100 
int a = 0

should throw a duplicate constant name error
2. var a: int should mirror int a behavior

@x87 x87 added type:bug Something isn't working priority:p2 Medium priority scope:compiler labels Nov 10, 2023
@x87
Copy link
Collaborator Author

x87 commented Nov 20, 2023

const a = $100 
int a = 0

is now a compile error (0090) in 4.0.0 beta.0

@x87 x87 mentioned this issue Dec 22, 2023
59 tasks
@x87 x87 added this to the v4.0.0 milestone Dec 22, 2023
@x87
Copy link
Collaborator Author

x87 commented Dec 22, 2023

var a: int

declares a new local variable (only in a CLEO script) in 4.0.0 beta.2

@x87
Copy link
Collaborator Author

x87 commented Aug 7, 2024

released in 4.0.0

@x87 x87 closed this as completed Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p2 Medium priority scope:compiler type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant