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
Deprecate auto-application of empty argument lists to parameterless functions #2124
Deprecate auto-application of empty argument lists to parameterless functions #2124
Conversation
3ffbca4
to
ef4f8a0
Compare
Inb4 " |
trigger warning |
Go away. In all seriousness though for anyone wondering though--while basically any Chisel API does have side effects, we go to great lengths to hide those side effects from the user such that Chisel APIs appear to be side effect free and therefore will follow the Scala style of not having parentheses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow Megan's suggestion on the deprecation messages (ie. they need to tell the user what to do). As I said in the comment, I don't think they need to mention the name of the method, but do need to say something like "use form without parentheses" or "use form of method without parentheses" or something.
Please also make the dummy argument style consistent. Since varargs are the only style that work for macros, I'd apply that throughout.
Also, please leave a blank line between a method definition and the start of the following definition (including when it's a deprecation annotation).
…hisel3 into migrate-zero-arity-funcs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every deprecation warning needs the version to be "Chisel 3.5"
, not just "3.5"
because the Scala compiler either doesn't know or at least doesn't report the name of the project that deprecation warnings come from.
final def asSInt: SInt = macro SourceInfoTransform.noArg | ||
@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "3.5") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final def asSInt: SInt = macro SourceInfoTransform.noArg | |
@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "3.5") | |
final def asSInt: SInt = macro SourceInfoTransform.noArg | |
@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "3.5") |
final def asBools: Seq[Bool] = macro SourceInfoTransform.noArg | ||
@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "3.5") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final def asBools: Seq[Bool] = macro SourceInfoTransform.noArg | |
@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "3.5") | |
final def asBools: Seq[Bool] = macro SourceInfoTransform.noArg | |
@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "3.5") |
this breaks dsptools.
|
reproducible in https://github.com/sequencer/playground/runs/3827353710 |
@jackkoenig @sequencer I think I might have figured this out. Looks like the macro expansions of do_unary_- are not defined for FixedPoint and Interval, not sure how everything worked before here but I'm testing a fix now |
In `Bits.scala`, `FixedPoint` and `Interval` did not defeine the `do_unary_-` methods (the `do_`) was missing The recent PR #2124 combined with the above fact made DspTools break. This fix is necessary to get that repo to build.
In `Bits.scala`, `FixedPoint` and `Interval` did not defeine the `do_unary_-` methods (the `do_`) was missing The recent PR #2124 combined with the above fact made DspTools break. This fix is necessary to get that repo to build.
super fast! |
Due to inlining of Boolean expressions, the following circuit is handled directly by the VerilogEmitter: input a: UInt<4> input b: SInt<1> output o: UInt<5> o <= dshl(a, asUInt(cvt(b))) Priot to this change, this could crash due to mishandling of cvt in the logic to inject parentheses based on Verilog precedence rules. This is a corner case, but similar bugs would drop up if we open up the VerilogEmitter to more expression inlining.
Scala 3 now enforces a distinction between nullary parameter-less functions and nullary functions with empty argument lists. Previously, Scala 2 would auto-apply an empty parameter list onto any invocation of a nullary parameter-less function.
As such, in order to migrate to Scala 3, any nullary function that doesn't induce a side effect, e.g.
asUInt
, must not include a parameter list in its invocation. To deprecate the use of empty parameter lists for these functions, dummy versions of these functions are included which explicitly allow use of an empty parameter list (for example, a default dummy argument or a vararg).Contributor Checklist
docs/src
?Type of Improvement
code refactoring
API Impact
No effect
Backend Code Generation Impact
No impact
Desired Merge Strategy
Squash and merge
Release Notes
Reviewer Checklist (only modified by reviewer)
3.3.x
, [small] API extension:3.4.x
, API modification or big change:3.5.0
)?Please Merge
?