Coder Social home page Coder Social logo

funky's People

Contributors

faiface avatar sammko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

funky's Issues

Type checker does not terminate checking recursive type alias

There are programs containing recursive type aliases (one fairly minimal example given below) where the type checker does not terminate trying to check if two overloads collide (in this case x) [see edit]:

alias T = T
func x : Int = 0
func x : T = x
func main : IO = quit

Edit: The type checker also hangs on even simpler snippets like the following:

alias T = T
func x : T = false
func main : IO = quit

You can substitute false with any term whose type is defined inside the language (via union and record) like "", [], nothing to reproduce this bug. Using primitive values (0, 'x', etcetera) on the right side, rightly produces a type error! Native types (Int, Float, Char) seem to be special-cased obviously.

Compiler crash on invalid semicolon syntax

The following malformed input causes the compiler to crash:

func main : IO = ;

Output:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x4e3bd8]

goroutine 1 [running]:
github.com/faiface/funky/parse.treeToFunc(0x575340, 0xc0002b64a0, 0xc0002b6460, 0xc0001eba30, 0x4, 0x4, 0x575340, 0xc0002b64a0)
	/home/fmease/.go/src/github.com/faiface/funky/parse/definitions.go:249 +0x158
github.com/faiface/funky/parse.TreeToDefinitions(0x575380, 0xc0002b8990, 0x8, 0x575380, 0xc0002b8990, 0x0, 0x0)
	/home/fmease/.go/src/github.com/faiface/funky/parse/definitions.go:60 +0x3ae
github.com/faiface/funky/parse.Definitions(0xc0000ab080, 0x6, 0x8, 0x0, 0xc0000ab080, 0x6, 0x8, 0x0)
	/home/fmease/.go/src/github.com/faiface/funky/parse/definitions.go:20 +0x92
github.com/faiface/funky.Run(0x54a6a2, 0x4, 0x54a626, 0x4)
	/home/fmease/.go/src/github.com/faiface/funky/run.go:58 +0x1454
main.main()
	/home/fmease/.go/src/github.com/faiface/funky/interpreters/funkycmd/main.go:14 +0x4b

Further information: The semicolon "applied" to only one instead of two arguments (0; and ;0) behaves like the identity function. If "applied" to zero arguments, it is treated as if it is not actually there provided it's preceded by an expression which resolves to a value. 0 (;) is treated as 0, self (;) 0 as self 0 and so on. Contrarily, expressions like (;) (;) (;) and (;) 0 cause a crash.

Compiler crash on invalid switch/case syntax

This code crashes the compiler:

func foo : a =
    switch 0
    case foozle
func bar : Int = 0 

With this error message:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x4d7643]

goroutine 1 [running]:
github.com/faiface/funky/expr.(*Switch).Map(0xc0002ae500, 0xc000563660, 0x51a780, 0x576901)
	/home/fmease/.go/src/github.com/faiface/funky/expr/expr.go:128 +0x113
github.com/faiface/funky/types/typecheck.instExpr(0xc0002f0148, 0x576b60, 0xc0002ae500, 0x576920, 0xc0004ed410)
	/home/fmease/.go/src/github.com/faiface/funky/types/typecheck/infer.go:576 +0x82
github.com/faiface/funky/types/typecheck.Infer(0xc0002b6e10, 0xc0006258d8, 0x576b60, 0xc0002ae500, 0xc0004ed110, 0x1, 0x1, 0x0, 0x0)
	/home/fmease/.go/src/github.com/faiface/funky/types/typecheck/infer.go:178 +0x72
github.com/faiface/funky/compile.(*Env).TypeInfer(0xc000625d50, 0x0, 0x0, 0x0)
	/home/fmease/.go/src/github.com/faiface/funky/compile/infer.go:40 +0x3f4
github.com/faiface/funky.Run(0x54a6a2, 0x4, 0x54a626, 0x4)
	/home/fmease/.go/src/github.com/faiface/funky/run.go:89 +0x44f
main.main()
	/home/fmease/.go/src/github.com/faiface/funky/interpreters/funkycmd/main.go:14 +0x4b

Because the parser does not handle the invalid sequence case x func. I expected the error message nothing after binding. The latter is output on input like (where EOF follows instead of the keyword func):

func foo : a =
    switch 0
    case foozle

Edit: Relates to #6 (which is more general).

Type annotations on some literals ignored

Per definition, the literal 0 is of type Int and the literal 0.0 is of type Float.
Thus, both lines below correctly fail to type-check:

(self : Int -> Int) 0.0
(self : Float -> Float) 0

For some reason though, type annotations directly placed on the literals seem to be ignored:

0.0 : Int # the whole expression is of type Float
0 : Float # the whole expression is of type Int

The expressions above pass the type-checker but clearly, they should not!

Edit: There might still be more cases like this. Another case:

'c' : Bool # type-checks
'c' : a # type-checks

Weirdly, this does not apply to string literals ("s" : Bool is an error). Edit: I assume this bug only applies to primitive values (types Int, Float, Char)!

Compiler crashes if a keyword is used as an identifier

If you use keywords (func, alias, record, union) in places where identifiers are expected, the compiler does not give a reasonable report but crashes. Faulty inputs might look like:

alias A = alias, record union or func func : Int = 0.

The crashes are caused by nil pointer dereferences.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.