fzyzcjy / dart_interactive

REPL (interactive shell) for Dart, supporting 3rd party packages, hot reload, and full grammar
https://github.com/fzyzcjy/dart_interactive
MIT License
217 stars 13 forks source link

Calling undefined getter on self defined class instance yields global variable #51

Closed Quijx closed 1 year ago

Quijx commented 1 year ago

Describe the bug When calling a non existing getter with the same name as a global variable on another global variable that holds an instance of a self defined class, the value of the first global variable is returned, instead of throwing a NoSuchMethodError.

To Reproduce

  1. Enter the following lines in order:
    
    >>> a=1
    1
    >>> class Foo {}
    >>> f=Foo()
    >>> f.a
    1


**Expected behavior**
A `NoSuchMethodError` is thrown, just like if you were to define `f='a string'` instead of `f=Foo()` for example.

**Actual Behavior**
The value of the global variable `a` is returned even though an instance of the class `Foo` clearly does not have a getter called `a`.
welcome[bot] commented 1 year ago

Hi! Thanks for opening your first issue here! :smile:

fzyzcjy commented 1 year ago

You are right, feel free to PR!

A good starting point is to look at the generated.dart file to see what is indeed generated