Skip to main content

13 - No Implicit Use For Function Call Arguments

From edition=13 onwards, function call arguments are no longer implicitly declared with use. This was a rarely-used feature and was more likely to cause accidental bugs than to be useful.

What's changed?

Previously behavior:

SomethingWithASubblock(audience=that.Owner) { // implicit `use audience = ...`
PolygonSprite(...) // Receives `audience` from context. Result: BUG! Why can't I see my sprite?
}

In the code snippet above, previously the audience parameter would be implicitly declared with use and so would affect the subblock, possibly in surprising and unintended ways.

Now the implicit use has been removed by default. If you still want this functionality, make the use explicit:

SomethingWithASubblock(use audience=that.Owner) {
PolygonSprite(...)
}

Upgrade instructions

First, set edition=13 (or higher) in your easel.toml file:

[engine]
edition = 13

ArrangeRing function for Acolyte Fight

If your game is a remix of Acolyte Fight, this section applies to you. Otherwise, skip to the next section.

Acolyte Fight was using this feature in only one place - the ArrangeRing function. We recommend you update your ArrangeRing function only, rather than changing 20 other files.

First, find the ArrangeRing function in your project in the file library/terrain/arrange.easel. The function signature should look something like this:

pub fn ArrangeRing(numObstacles, orbit, headingOffset=0, angleOffset=0, pattern=null) |use posOffset, use headingOffset| {

Add use orbit at the end of the subblock parameter list between the | characters:

pub fn ArrangeRing(numObstacles, orbit, headingOffset=0, angleOffset=0, pattern=null) |use posOffset, use headingOffset, use orbit| {

That's all you need to do! Easel now automatically puts the orbit variable into context for the subblock, which effectively re-introduces the implicit use just for this parameter where it is needed.

Add use to any other parameters

If you get any compile errors after upgrading to edition=13 that say something like missing required argument 'color', it means there was an implicit use that you must now make explicit.

If your parameter is called color for example, find the function call with the parameter color and change it to use color.

For example, if your error is happening in a function like this:

SomethingWithASubblock(color=#bb00ff) {
PolygonSprite(...)
}

Change it to:

SomethingWithASubblock(use color=#bb00ff) {
PolygonSprite(...)
}

Now your code should be working!

Opt-out

If you would like to temporarily opt-out your entire project from this change, you can set useFunctionCallArgumentsImplicitly=true in legacy.toml, like this:

[legacy]
useFunctionCallArgumentsImplicitly = true