question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using template substitution in a function silently makes it unusable in a annotation

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting

Current behavior

The following function:

export function ANIM_EXPAND_WIDTH(transitionMs: number = 200): AnimationEntryMetadata {
    return trigger('expandWidth', [
        state('void', style({
            width: 0
        })),
        state('*', style({
            width: '*'
        })),
        transition('void <=> *', animate(`${transitionMs}ms ease`))
    ]);
}

from a library causes the the error Error encountered resolving symbol values statically. Calling function 'ANIM_EXPAND_WIDTH' with no indication as why it is not be used as a macro function.

The subtle change to:

export function ANIM_EXPAND_WIDTH(transitionMs: number = 200): AnimationEntryMetadata {
    return trigger('expandWidth', [
        state('void', style({
            width: 0
        })),
        state('*', style({
            width: '*'
        })),
        transition('void <=> *', animate(transitionMs+'ms ease'))
    ]);
}

works.

Expected behavior

Either this template substitution should be supported or a clear error message about why it can’t be supported should be reported.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
JoostKcommented, Mar 14, 2020

This is no longer an issue with Ivy 😃

2reactions
fknopcommented, Dec 16, 2016

Same error happens if we use a variable inside the function for example:

const transform: string = 'translate(0, 25%)'; and use this variable to avoid retyping the css value.

Also using a switch will not work:

export function fadeSlide (direction: string = 'down', duration: number = 0.2): AnimationEntryMetadata {

  let transform: string;

  switch (direction) {
    case 'up':    transform = 'translate(0, 25%)'; break;
    case 'down':  transform = 'translate(0, -25%)'; break;
    case 'left':  transform = 'translate(25%, 0)'; break;
    case 'right': transform = 'translate(-25%, 0)'; break;
    default: throw new Error('Unknown direction ' + direction + ' for slide animation');
  }

  return trigger('fadeSlide', [
    transition(':enter', [
      style({
        opacity: 0,
        transform: transform
      }),
      animate(duration + 's ease-in-out')
    ]),
    transition(':leave', [
      animate(duration + 's ease-in-out', style({
        opacity: 0,
        transform: transform
      }))
    ])
  ]);
}

I feel like it should work. The parameters passed inside the function should be enough to resolve the value of the variable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PEP 484 – Type Hints - Python Enhancement Proposals
In its basic form, type hinting is used by filling function annotation slots with classes: def greeting(name: str) -> str: return 'Hello '...
Read more >
Why does this substitution failure create an error?
Your code is ill-formed (no diagnostic required) because the condition is always false regardless of the template argument, ...
Read more >
Common Function Attributes (Using the GNU Compiler ...
The unavailable attribute results in an error if the function is used anywhere in the source file. This is useful when identifying functions...
Read more >
Resolver mapping template programming guide - AWS AppSync
Resolver mapping template programming guide ... This is a cookbook-style tutorial of programming with the Apache Velocity Template Language (VTL) in AWS AppSync....
Read more >
User Guide - Apache Velocity Engine
Velocity is a Java-based template engine. It permits web page designers to reference methods defined in Java code. Web designers can work in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found