Skip to content

[BUG] Un-declared variables cause not graceful error messages #62

@Pillber

Description

@Pillber

Describe the bug
When using a variable that has not been declared using let, instead of a nice raven error, the SimpleVariableManager panics.

Raven Code To Reproduce
In core/src/string.rv:

impl Cast<str> for u64 {
    pub fn cast(self, number: u64) -> str {
        do {
            let digit = number % 10;
            let char_digit = '0' + digit;
            output = char_digit + output;
            number /= 10;
        } while(number != 0);
    }
}

Here, the variable output is undeclared.

Error Output or Unexpected Behavior

Unresolved variable output from SimpleVariableManager { variables: {"self": Reference(Struct(FinalizedStruct { generics: {}, fields: [],
 data: u64 })), "digit": Reference(Reference(Struct(FinalizedStruct { generics: {}, fields: [], data: u64 }))), "number": Reference(Stru
ct(FinalizedStruct { generics: {}, fields: [], data: u64 })), "char_digit": Reference(Struct(FinalizedStruct { generics: {}, fields: [],
 data: char }))} }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'test::test::test_magpie' panicked at language\runner\src\lib.rs:58:25:
task 157 panicked

As far as I can tell, it is mad that output is being used, but it isn't one of those fancy parsing/syntax errors that someone has made

Additional context
More testing should be done around this. I just found this error and haven't done much to reproduce it, as it is the second error I have found while just trying to do number->string casting. I'll try and update this with more info when/if I get around to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions