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

an object with bytes must have text content #77

Open
yegor256 opened this issue Dec 2, 2024 · 5 comments · May be fixed by #171
Open

an object with bytes must have text content #77

yegor256 opened this issue Dec 2, 2024 · 5 comments · May be fixed by #171
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@yegor256
Copy link
Member

yegor256 commented Dec 2, 2024

This is not a valid XMIR:

<o base="org.eolang.string" name="foo">
  <o base="org.eolang.bytes"/>
</o>

An object with base="org.eolang.bytes" must have text() content. Let's create a new lint to check for this.

@h1alexbel
Copy link
Contributor

@yegor256 I can work on this

h1alexbel added a commit to h1alexbel/lints that referenced this issue Dec 25, 2024
@h1alexbel h1alexbel linked a pull request Dec 25, 2024 that will close this issue
@maxonfjvipon
Copy link
Member

@yegor256 I think it's a valid XMIR. Consider the next code.
EO:

string bytes > x

XMIR:

<o base="string" name="x">
  <o base="bytes"/>
</o>

@yegor256
Copy link
Member Author

@maxonfjvipon I would make it an error. The right way to do it is this:

string -- > x

@maxonfjvipon
Copy link
Member

maxonfjvipon commented Dec 26, 2024

@yegor256 so you suggest to prohibit explicit usage of bytes?

Since recently bytes has one free attribute which should (but not must) be an abstract with \Delta.

But the next case looks valid:

string
  bytes
    []
      string > @
        01-

Yes, 99% will never write like this, but it's valid and dataizable

Maybe it's a bug in EO, because now we have differences between how bytes with data is presented in EO(or PHI) and XMIR:

PHI:

{[x -> Ф.org.eolang.string(
  a0 -> Ф.org.eolang.bytes(
    a0 -> [\Delta -> 00-00-00-00] # anonymous abstract object as argument
  )
)]}

XMIR

<o base="string">
  <o base="bytes">
    00-00-00-00 // no anonymous abstract object
  </o>
</o>

For now such presentation in XMIR is just more convenient than if we have one extra <o> element inside bytes

Java:

new PhWith(
  Ф.take("org.eolang.bytes").copy(),
  0,
  new PhDefault(new byte[] {...}) // also anonymous abstract object 
)

@yegor256
Copy link
Member Author

@maxonfjvipon I suggest we fix the XMIR, to make it aligned with phi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants