radon-project / radon

The Radon Programming Language
https://radon-project.github.io
GNU General Public License v3.0
23 stars 2 forks source link

[BUG]: Scope related issue. #100

Closed Almas-Ali closed 2 months ago

Almas-Ali commented 2 months ago

Describe the bug When accessing a variable in a class (BuiltInInstance) it is giving undefined. I think it is related to scoping issue, which is introduced by #98.

Screenshots or Code snippets

string1 = "this is my string."
string_obj = String(string1)

v = "i"
count = string_obj.count(v) # Runtime Error: 'v' is not defined
angelcaru commented 2 months ago

Tested this and it works if you do (string_obj.count)(v). I think we need to update our parser to parse it the same way

Almas-Ali commented 2 months ago

Tested this and it works if you do (string_obj.count)(v). I think we need to update our parser to parse it the same way

Very weird syntax! We need fix this soon.

angelcaru commented 2 months ago

I think it is because it runs the whole count(v) in the context of the string, instead of just fetching count and calling it from outside (And the string has no v). This bit me several times in the development of #98, so we definitely need to fix it soon.

angelcaru commented 2 months ago

Tested this and it works if you do (string_obj.count)(v). I think we need to update our parser to parse it the same way

Nevermind, it actually crashes in Python