Skip to content

Condition in switch case is ignored during compilation #63

@serjek

Description

@serjek

Consider following example:

@:attr var value:Option<Int>;

function render()
<View>
	<switch $value>
		<case ${Some(v) if (v > 0)}><Text>some $v</Text>
		<case $None><Text>none</Text>
	</switch>
</View>;

There are 2 problems here:

  • it compiles. Instead of this it should be requiring to handle Some(x) case
  • when compiled there is no condition if (v > 0) anymore:
__coco_render: function() {
  var _g = tink_state_Observable.get_value(this.__coco_value);
  var children;
  switch(_g._hx_index) {
  case 0:
	  var v = _g.v;
	  var __r = [];
	  __r.push("some ");
	  __r.push(v);
	  var cls = react_native_component_Text;
	  var children1 = [cls.__jsxStatic != null ? cls.__jsxStatic : cls,{ }].concat(__r);
	  children = React.createElement.apply(React,children1);
	  break;
  case 1:
	  var cls = react_native_component_Text;
	  var children1 = [cls.__jsxStatic != null ? cls.__jsxStatic : cls,{ }].concat(["none"]);
	  children = React.createElement.apply(React,children1);
	  break;
  }
  var cls = react_native_component_View;
  var tmp = [cls.__jsxStatic != null ? cls.__jsxStatic : cls,{ }].concat([children]);
  return React.createElement.apply(React,tmp);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions