mrodz / mscript

Programming Language
Apache License 2.0
4 stars 1 forks source link

[report] Incorrectly passing function arguments #154

Closed mrodz closed 9 months ago

mrodz commented 9 months ago

Documentation Status

Snippet Responsible

import lib

print lib.version

lib.drawPixel(40, 20)

class D {
    fn drawPixel2(self) {
        lib.drawPixel(40, 20)
    }
}
lib.drawPixel(40, 20) # CASE 1: works fine
(D()).drawPixel2()    # CASE 2: crashes and passes <module lib> as the first argument to `lib.drawPixel`

Stack Trace of Error

thread 'Main' panicked at compiler\src\ast\function_arguments.rs:59:21:
internal error: entered unreachable code: <module ".\\lib.ms">
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at src\main.rs:163:32:
called `Result::unwrap()` on an `Err` value: Any { .. }

Expected Behavior

lib.drawPixel is not an associated function, and should not take module as the first argument.

Any ideas where MScript breaks?

Brain Dump (Optional)

Previously, this bug also emerged for CASE 1 but was resolved by explicitly checking for this edge case. To fix CASE 2, I might have to look into more core parsing behavior to find the root of the issue.