[ 
https://issues.apache.org/jira/browse/DAFFODIL-2628?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17685436#comment-17685436
 ] 

Mike McGann commented on DAFFODIL-2628:
---------------------------------------

I've narrowed it down a bit. The following:

{{<dfdl:assert test="\{dfdlx:trace(42, 'answer')}"/>}}

compiles to this:

{{<CompiledDPath>
  }}{{<DFDLXTrace>
    <CompiledDPath>
      <Literal>DataValue(42)</Literal>
      <IntToLong/>
      }}{{<LongToBoolean/>
    }}{{</CompiledDPath>
  }}{{</DFDLXTrace>
  <IntToLong/>
  <LongToBoolean/>
</CompiledDPath>}}

For some reason, the conversion from int to bool is being done twice.

At this line here:

[https://github.com/apache/daffodil/blob/v3.4.0/daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala#L2486]

if I change:

{{new CompiledDPath(DFDLXTrace(realArg.compiledDPath, msgText) +: conversions)}}

to:

{{new CompiledDPath(DFDLXTrace(realArg.compiledDPath, msgText))}}

then it works but I suspect that isn't the correct solution. I'm having a hard 
time looking at the code and figuring out why it wants to convert it twice. 
[~mbeckerle]: Any guidance on where I should be looking? 

> 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 &quot;End&quot;
>    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)

Reply via email to