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

[E2] Internal error but no compiler error/warning when trying to do operations on not-yet-defined variable #3016

Open
CheezusChrust opened this issue Mar 16, 2024 · 2 comments
Labels

Comments

@CheezusChrust
Copy link
Contributor

Describe the bug
sv: Expression 2 (oops): Internal error 'entities/gmod_wire_expression2/core/number.lua:81: attempt to perform arithmetic on local 'lhs' (a nil value)' at line 8, char 1

To Reproduce

@name bug
@strict

function bruh() {
    Piss = 5
}

print(Piss + 2)

Expected behavior
A compiler error or something

@Fasteroid
Copy link
Contributor

Fasteroid commented Jul 11, 2024

Oh god are you the same cheeze that made the horribly uncompressed button textures?

@Vurv78
Copy link
Contributor

Vurv78 commented Aug 6, 2024

This is intentional since @strict doesn't replace globals every time now, but I think it really should initialize on the first go, at least, since that wouldn't cost much.

That or make the compiler not stupid and include the scoping when deciding if a variable has already been assigned to. I'd prefer that.

ie

existing.initialized = true
should also write down the scopeid it was initialized at (careful to only assign if currentid < assignid), then just check if assignid < currentid when checking if the variable is initialized or not.

Then you'll at least get a warning in advance.

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

4 participants