question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type after shift in IntelliJ

See original GitHub issue

Maybe this is just a bug in IntelliJ, but let’s see if someone has an idea.

Type of issue: bug report

Following code

  val a = 1.U << 1
  val b = 3.U
  println(a, b)

  // IntelliJ editor complains on 'a': Type mismatch, expected UInt, actual: Bits
  when(b >= a) {
    io.data := 1.U
  }

displays an error in the IntelliJ editor (a is marked in the when expression). The editor thinks that the shift operation in the first line results in Bits and not a UInt.

However, the code compiles correctly with IntelliJ and also with sbt from the terminal.

What, in the Chisel type system, is confusing the IntelliJ editor here?

Please tell us about your environment: -version 3.1.8

  • IntelliJ latest on Mac (just updated)

The example is available here: https://github.com/schoeberl/chisel-playground/blob/master/src/main/scala/issues/Shift.scala

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ducky64commented, Jul 19, 2019

Implicit conversions: there’s been some discussion on making the separation of Bits and UInt better, so it might not be safe to have Bits automatically cast to UInt.

I think a typeclass solution on Bits makes sense, and I remember hearing that having macros change the return type was discouraged and may go away in a future Scala version. One caveat here is that it needs to not bleed into the user facing API (this is what prevented a typeclass approach to static-typed literals - it would have required something like MyBundle extends Bundle with StaticLiteral[MyBundle]), but since this only affects the Bits hierarchy (which we don’t expect users to extend), that shouldn’t be a problem

1reaction
schoeberlcommented, Jul 19, 2019

BTW, the same issue is true with Eclipse 😦

And another example:

  val blkReg = Reg(UInt(1.W))

  cntReg := cntReg + 1.U
  when(cntReg === CNT_MAX) {
    cntReg := 0.U
    blkReg := ~blkReg
  }
  io.led := blkReg
}

on blkReg := ~blkReg it complains with a type mismatch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IntelliJ IDEA keyboard shortcuts - JetBrains
Press Ctrl+Shift+A and start typing to get a list of suggested actions. Then select the necessary action and press Enter to execute it....
Read more >
Keyboard shortcuts: keymaps comparison (Windows) - JetBrains
Basic editing ; Join Lines. Ctrl+Shift+J · Ctrl+Shift+J · Ctrl+Shift+J ; Duplicate Line or Selection. Ctrl+D · Ctrl+D · Ctrl+D.
Read more >
Top 15 IntelliJ IDEA Shortcuts - The JetBrains Blog
⌥↑ / ⌥↓ or Ctrl + W / Shift + Ctrl + W ... We can select increasing or decreasing sections of code...
Read more >
Troubleshooting problems with keyboard shortcuts - JetBrains
Press Ctrl+Alt+S to open the IDE settings and select Keymap. Make sure that you are using the correct keymap. Use the search field...
Read more >
Configure keyboard shortcuts | IntelliJ IDEA Documentation
For example, you can press Ctrl+Shift+A and type the name of the Jump to Colors and Fonts action to quickly modify the color...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found