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

Runtime vs Compiletime errors (Type System ?) #13

Open
hgzimmerman opened this issue Oct 8, 2017 · 0 comments
Open

Runtime vs Compiletime errors (Type System ?) #13

hgzimmerman opened this issue Oct 8, 2017 · 0 comments

Comments

@hgzimmerman
Copy link
Owner

Possibly split the LangError type into runtime and compile/parse time errors.

This is probably hard given how fuzzy the compile-time vs runtime logic is right now.

A lot of runtime errors that could be compiletime errors are type checking related. These could be evaluated at compiletime by implementing add, subtract, multiplication, etc... to the TypeInfo class and allowing tracking of types through the AST by converting each datatype into a TypeInfo, and performing the logic on it to determine if the types match.

As an example, consider this function:

fn function(value: Number ) -> Number {
    let x := value + 1.0
    x
}

Under the new typechecking system, it could convert that to something like this:

fn function(value: Number ) -> Number {
    let x := value->Number + Float
    x->Float
}

Because Number + Float is a Float, returning x should not be possible because the return type is a Number. This should throw a compile time error indicating the type mismatch.

@hgzimmerman hgzimmerman changed the title Runtime vs CompileTime errors Runtime vs CompileTime errors (Type System ?) Oct 8, 2017
@hgzimmerman hgzimmerman changed the title Runtime vs CompileTime errors (Type System ?) Runtime vs Compiletime errors (Type System ?) Oct 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant