[
https://issues.apache.org/jira/browse/DAFFODIL-2628?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17685458#comment-17685458
]
Steve Lawrence commented on DAFFODIL-2628:
------------------------------------------
I *think* the issue is this line:
{code:scala}
override def targetTypeForSubexpression(subExp: Expression): NodeInfo.Kind =
targetType
{code}
This is saying the the target type for the subexpression (i.e. realArg), is
"targetType", which in {{FunctionCallBase}} is defined as "parent.targetType".
So this line is saying that the realArg needs to be converted to
"parent.targetType" (i.e. boolean in this case) before DFDLXTrace handles it.
But I don't think that is right. DFDLXTrace should output the value exactly as
it is passed in without any conversions. And then the conversion to the
targetType only happens after DFLXTrace returns. So we do want the "+:
conversion" here as you suggest.
I think what we want instead is to say that the targetTypeForSubExpression is
something different, maybe just "realArg.inherentType"? That way we say the
targetType for realArg is whatever realArg naturally returns and so it won't do
any conversions. And then because we have the "+: conversions" here, whaever
that returns will be converted to whatever the caller of dfdlx:trace expects.
So in your example dfdlx:trace should ouput the int value of "42", and than
that gets converted to a boolean since that's what the assert expects.
> abort: invariant broken when assert test expression does not return boolean
> ---------------------------------------------------------------------------
>
> Key: DAFFODIL-2628
> URL: https://issues.apache.org/jira/browse/DAFFODIL-2628
> Project: Daffodil
> Issue Type: Bug
> Components: Back End, Middle "End"
> Affects Versions: 3.2.1
> Reporter: Mike Beckerle
> Assignee: Mike McGann
> Priority: Major
> Fix For: 3.5.0
>
>
> Debugging a schema I created this little thing to print out a length I wanted
> to see:
> ```
> <dfdl:assert test='{ dfdlx:trace(dfdl:valueLength(message,
> "bytes"),"contentLen") }'/>
>
> ```
> Notice the mistake. I forgot to compare the value to 0 in the test.
> That expression returns an integer.
> If you fix the expression (add " ge 0") then everything works fine.
> But with the mistake you get an abort at runtime:
> ```
> trace contentLen:DataValue(true)
> org.apache.daffodil.exceptions.Abort: Invariant broken. Runtime.scala -
> Leaked exception: java.lang.ClassCastException: class java.lang.Boolean
> cannot be cast to class java.lang.Long (java.lang.Boolean and java.lang.Long
> are in module java.base of loader 'bootstrap')
> java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class
> java.lang.Long (java.lang.Boolean and java.lang.Long are in module java.base
> of loader 'bootstrap')
> at
> org.apache.daffodil.infoset.DataValue$.getLong$extension(DataValue.scala:78)
> at
> org.apache.daffodil.dpath.LongToBoolean$.computeValue(ConverterOps.scala:155)
> at
> org.apache.daffodil.dpath.LongToBoolean$.computeValue(ConverterOps.scala:153)
> at org.apache.daffodil.dpath.Converter.run(DPathRuntime.scala:294)
> at org.apache.daffodil.dpath.CompiledDPath.run(DPathRuntime.scala:141)
> at
> org.apache.daffodil.dpath.CompiledDPath.runExpression(DPathRuntime.scala:72)
> ```
--
This message was sent by Atlassian Jira
(v8.20.10#820010)