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

Panic in field array dim calculation #161

Closed
kossnikita opened this issue Oct 2, 2023 · 7 comments · Fixed by #162
Closed

Panic in field array dim calculation #161

kossnikita opened this issue Oct 2, 2023 · 7 comments · Fixed by #162

Comments

@kossnikita
Copy link
Contributor

EXINT:
  INTEN:
    _array:
      INTEN?,INTEN10:
        description: "Interrupt enable or disable on line %s"

Token boundaries are calculated without comma split.

let (li, ri) = spec_ind(fspec);

li = 5, ri = 8
thread 'main' panicked at 'byte index 18446744073709551614 is out of bounds of `INTEN0`', src\patch\register.rs:383:30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

.map(|f| f.name[li..f.name.len() - ri].to_string())

@burrbull
Copy link
Member

burrbull commented Oct 2, 2023

I know about this issue, but I don't know good way to fix it.

@burrbull
Copy link
Member

burrbull commented Oct 2, 2023

#162 should help for your specific situation, but this is just a patch.

@burrbull
Copy link
Member

burrbull commented Oct 2, 2023

Although this can break other use cases.

@kossnikita
Copy link
Contributor Author

Yes, works in this case

EXINT:
  INTEN:
    _array:
      INTEN?,INTEN1[0-7]:
        description: "Interrupt enable or disable on line %s"
<fields>
  <field>
    <dim>18</dim>
    <dimIncrement>0x1</dimIncrement>
    <dimIndex>0-17</dimIndex>
    <name>INTEN%s</name>
    <description>Interrupt enable or disable on line %s</description>

But don't work there (I don't know why someone would write such a weird patch)

EXINT:
  INTEN:
    _array:
      INTEN1[0-7],INTEN?:
        description: "Interrupt enable or disable on line %s"
<fields>
  <field>
    <dim>18</dim>
    <dimIncrement>0x1</dimIncrement>
    <dimIndex>,,,,,,,,,,0,1,2,3,4,5,6,7</dimIndex>
    <name>INTEN1%s</name>
    <description>Interrupt enable or disable on line %s</description>

@burrbull
Copy link
Member

burrbull commented Oct 2, 2023

I don't have better ideas.

P.S. We need someone to improve YAML Format as patch format was much extended since last docs edition. Do you have a wish to help? I'm bad in doc writing. (#5)

@kossnikita
Copy link
Contributor Author

As far as I know, the functionality of rust and python is now slightly different. Should this be reflected in the documentation or should the new syntax be introduced into Python first?

@burrbull
Copy link
Member

burrbull commented Oct 2, 2023

Python version is deprecated, but we try to support it if it is not hard. For example #162 is easy, but I can't say the same for #159 (the magic that it needed is in svd-rs). For now differences are not big.

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

Successfully merging a pull request may close this issue.

2 participants