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

Playground: Module validation failed #5814

Open
alex2io opened this issue Mar 12, 2018 · 6 comments
Open

Playground: Module validation failed #5814

alex2io opened this issue Mar 12, 2018 · 6 comments

Comments

@alex2io
Copy link

alex2io commented Mar 12, 2018

class DataType(T)
  def initialize(@name : String, @type : T.class)
  end
end

list = [] of DataType(String | Int32)

data_type = DataType.new "text", String
list << data_type
Exception
Module validation failed: Function return type does not match operand type of return inst!
  ret i32* %1, !dbg !11
 %"DataType(Int32 | String)"*

Crystal 0.24.1 (2018-01-27) LLVM: 5.0.1 Default target: x86_64-apple-macosx

@Virtual-Machine
Copy link

I checked and this bug is not present on https://play.crystal-lang.org/#/cr

It is occurring on my machine.
Crystal 0.24.2 (2018-03-10) LLVM: 5.0.1 Default target: x86_64-apple-macosx.

This is the verbose terminal output for the error.

I, [2018-03-31 22:25:58 -04:00 #3103]  INFO -- : /client WebSocket connected as session=1
I, [2018-03-31 22:25:58 -04:00 #3103]  INFO -- : Request to run code (session=1, tag=1).
class DataType(T)
  def initialize(@name : String, @type : T.class)
  end
end

list = [] of DataType(String | Int32)

data_type = DataType.new "text", String
list << data_type
I, [2018-03-31 22:25:58 -04:00 #3103]  INFO -- : Code instrumentation (session=1, tag=1).
class DataType(T)
  def initialize(name : String, type : T.class)
    @name = name
    @type = type
  end
end
list = _p.i(6) do
  [] of DataType(String | Int32)
end
data_type = _p.i(8) do
  DataType.new("text", String)
end
_p.i(9) do
  list << data_type
end

I, [2018-03-31 22:25:58 -04:00 #3103]  INFO -- : Instrumented code compilation started (session=1, tag=1).
I, [2018-03-31 22:25:59 -04:00 #3103]  INFO -- : Instrumented code compilation failed (session=1, tag=1).
I, [2018-03-31 22:25:59 -04:00 #3103]  INFO -- : Original code compilation started (session=1, tag=1).
E, [2018-03-31 22:25:59 -04:00 #3103] ERROR -- : Instrumention bug found (session=1, tag=1).

@jhass
Copy link
Member

jhass commented Jul 1, 2019

Not reproducible anymore in Crystal 0.29.0

@jhass jhass closed this as completed Jul 1, 2019
@jhass
Copy link
Member

jhass commented Jul 1, 2019

Oh actually never mind, it just took a bit for the error to load

@vlazar
Copy link
Contributor

vlazar commented Oct 14, 2019

Is this still an issue? There is no exception in original example anymore.

Crystal 0.31.1 on MacOS
$ crystal --version
Crystal 0.31.1 (2019-10-02)

LLVM: 8.0.1
Default target: x86_64-apple-macosx

@vlazar
Copy link
Contributor

vlazar commented Oct 14, 2019

🤦‍♂ Disregard my previous message. Overlooked it's a bug in playground. Still happening.

@HertzDevil
Copy link
Contributor

This now produces:

error in line 9
Error: instantiating 'Array(DataType(Int32 | String))#<<(DataType(String))'


In /usr/share/crystal/src/array.cr:409:5

 409 | push(value)
       ^---
Error: instantiating 'push(DataType(String))'


In /usr/share/crystal/src/array.cr:1439:12

 1439 | @buffer[@size] = value
               ^
Error: instantiating 'Pointer(DataType(Int32 | String))#[]=(Int32, DataType(String))'


In /usr/share/crystal/src/pointer.cr:130:29

 130 | (self + offset).value = value
                               ^----
Error: type must be DataType(Int32 | String), not DataType(String)

The fact this used to compile was the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
@vlazar @jhass @HertzDevil @alex2io @Virtual-Machine and others