Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/styles/config/vocabularies/Custom/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ inlined
[Ii]nlining
[Ss]ubgraph
[Aa]pplication
[Ff]orma(e)?
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
* SPDX-License-Identifier: MIT
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" version="2.0" id="package-member-without-void">
<xsl:import href="/org/eolang/parser/_funcs.xsl"/>
<xsl:import href="/org/eolang/funcs/lineno.xsl"/>
<xsl:import href="/org/eolang/funcs/escape.xsl"/>
<xsl:import href="/org/eolang/funcs/defect-context.xsl"/>
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:template match="/">
<defects>
<xsl:if test="/object/metas/meta[head='package']">
<xsl:for-each select="/object/o[eo:abstract(.) and @name and not(o[eo:void(.)])]">
<defect>
<xsl:variable name="line" select="eo:lineno(@line)"/>
<xsl:attribute name="line">
<xsl:value-of select="$line"/>
</xsl:attribute>
<xsl:if test="$line = '0'">
<xsl:attribute name="context">
<xsl:value-of select="eo:defect-context(.)"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="severity">warning</xsl:attribute>
<xsl:text>The package member </xsl:text>
<xsl:value-of select="eo:escape(@name)"/>
<xsl:text> does not declare any void attributes, so it can never be reached in the implicit (receiver) form, only through the package namespace</xsl:text>
</defect>
</xsl:for-each>
</xsl:if>
</defects>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Package member without void

A member of a package is also implicitly a method of any object whose forma
matches the package name. `bytes.as-number x` and `x.as-number` reach the
same `Φ.bytes.as-number` object, because the runtime binds the receiver into
the member's first void attribute when the implicit, dotted form is used.

A member that declares no void attributes has no slot for that receiver.
The implicit form fails at runtime then, even though the explicit,
package-qualified form works fine.

Incorrect:

```eo
+package bytes

# As number.
[] > as-number
```

Correct:

```eo
+package bytes

# As number.
[b] > as-number
```

Only top-level objects of a file that declares `+package` are checked. A
void-less formation is fine everywhere else: a ready-made constant such as
`[] > stdin`, or a local helper nested inside another formation's body.

See [objectionary/lints#1170] for the discussion that motivated this lint.

[objectionary/lints#1170]: https://github.com/objectionary/lints/issues/1170
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/design/package-member-without-void.xsl
defects: 0
input: |
+package foo

# Bar.
[x] > bar
# Baz.
[] > baz
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/design/package-member-without-void.xsl
defects: 0
input: |
+package foo

# Bar.
[x] > bar
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/design/package-member-without-void.xsl
defects: 0
input: |
# Stdin.
[] > stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/design/package-member-without-void.xsl
asserts:
- /defects[count(defect[@severity='warning'])=1]
- /defects/defect[@line='4']
input: |
+package foo

# Bar.
[] > bar /number
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/design/package-member-without-void.xsl
asserts:
- /defects[count(defect[@severity='warning'])=1]
- /defects/defect[@line='4']
input: |
+package foo

# Bar.
[] > bar
# Baz.
[] > baz
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/design/package-member-without-void.xsl
asserts:
- /defects[count(defect[@severity='warning'])=1]
- /defects/defect[@line='4']
input: |
+package foo

# Bar.
[] > bar
Loading