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

Cannot use self in field &convert expressions #1261

Closed
bbannier opened this issue Aug 15, 2022 · 0 comments · Fixed by #1270
Closed

Cannot use self in field &convert expressions #1261

bbannier opened this issue Aug 15, 2022 · 0 comments · Fixed by #1270
Assignees
Labels
Bug Something isn't working

Comments

@bbannier
Copy link
Member

It looks like self cannot be used in field &convert expressions; using self in a unit &convert attribute like mentioned in the docs works though.

# foo.spicy
module foo;

public type X = unit {
	len: uint8;
	x: bytes &eod &convert=self.len;
	# x: bytes &eod &convert=f($$, self.len); # Originally intended use.
};

function f(x: bytes, len: uint8): string {
	return "";
}
$ spicyc -j foo.spicy
[error] foo.spicy:5:25: unknown ID 'self'
[error] spicyc: aborting after errors
@bbannier bbannier added the Bug Something isn't working label Aug 15, 2022
@rsmmr rsmmr self-assigned this Sep 26, 2022
rsmmr added a commit that referenced this issue Sep 28, 2022
…essions.

`self` is special in that it creates cycles that can prevent a type
from considered being fully resolved when we need it. We now
generally consider 'self` expressions as fully resolved to break that
cycle.

Closes #1261.
@bbannier bbannier linked a pull request Sep 28, 2022 that will close this issue
rsmmr added a commit that referenced this issue Sep 28, 2022
…essions.

`self` is special in that it creates cycles that can prevent a type
from considered being fully resolved when we need it. We now
generally consider 'self` expressions as fully resolved to break that
cycle.

Closes #1261.
rsmmr added a commit that referenced this issue Sep 30, 2022
…essions.

`self` is special in that it creates cycles that can prevent a type
from considered being fully resolved when we need it. We now
generally consider 'self` expressions as fully resolved to break that
cycle.

Closes #1261.
@rsmmr rsmmr closed this as completed in 3226b8b Oct 5, 2022
rsmmr added a commit that referenced this issue Oct 5, 2022
* topic/robin/gh-1261-self-convert:
  Disallow `self` as ID in declarations.
  Fix inability to access unit fields through `self` in `&convert` expressions.
  Fix accidental lookup of empty IDs.
  Add helper script to diff two AST.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants